Skip to content

Commit c539c14

Browse files
committed
refactor(cli): move process-exit lifecycle to CLI boundary
1 parent 5f5b8e8 commit c539c14

6 files changed

Lines changed: 6 additions & 6 deletions

File tree

‎src/bin.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ function runNoCommandFastPath(argv: string[]): boolean {
3939
process.stdout.write(`${buildUsageText()}\n`);
4040
// #1596: exitAfterFlush (not a bare process.exit) so the full usage
4141
// text reaches a piped caller before the process terminates.
42-
const { exitAfterFlush } = await import('./utils/process-exit.ts');
42+
const { exitAfterFlush } = await import('./cli/process-exit.ts');
4343
await exitAfterFlush(1);
4444
})
4545
.catch(handleStartupError);
@@ -120,7 +120,7 @@ function runCli(argv: string[]): void {
120120
function handleStartupError(error: unknown): void {
121121
process.stderr.write(`${error instanceof Error ? error.message : String(error)}\n`);
122122
// #1596: exitAfterFlush so the message above isn't dropped on a piped stderr.
123-
import('./utils/process-exit.ts')
123+
import('./cli/process-exit.ts')
124124
.then(({ exitAfterFlush }) => exitAfterFlush(1))
125125
.catch(() => process.exit(1));
126126
}

‎src/cli.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
} from '@agent-device/kernel/errors';
1010
import { resolveRemoteRequestDiagnosticsPath } from './daemon/session-store.ts';
1111
import { printHumanError, printJson } from './utils/output.ts';
12-
import { exitAfterFlush } from './utils/process-exit.ts';
12+
import { exitAfterFlush } from './cli/process-exit.ts';
1313
import { readVersion } from '@agent-device/host-kit/version';
1414
import { pathToFileURL } from 'node:url';
1515
import { sendToDaemon } from './daemon/client/daemon-client.ts';

‎src/cli/process-entry.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { exitAfterFlush } from '../utils/process-exit.ts';
1+
import { exitAfterFlush } from './process-exit.ts';
22

33
type CliModule = {
44
runCli(argv: string[]): Promise<void>;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ vi.mock('@agent-device/host-kit/retry', async (importOriginal) => {
66
return { ...actual, sleep: vi.fn(async () => {}) };
77
});
88

9-
import { exitAfterFlush } from '../process-exit.ts';
9+
import { exitAfterFlush } from './process-exit.ts';
1010
import { sleep } from '@agent-device/host-kit/retry';
1111

1212
type FakeWriteStream = {

‎test/integration/support/exit-after-flush.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import https, { type RequestOptions } from 'node:https';
44
import { EventEmitter } from 'node:events';
55
import { Readable } from 'node:stream';
6-
import { exitAfterFlush } from '../../../src/utils/process-exit.ts';
6+
import { exitAfterFlush } from '../../../src/cli/process-exit.ts';
77
import { buildPayload, PAYLOAD_MARKER } from './exit-payload.ts';
88

99
const DAEMON_BASE_URL = 'https://agent-device-exit-flush.test/agent-device';

0 commit comments

Comments
 (0)