@travetto/cli 7.1.1 → 7.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -498,7 +498,8 @@ export class WebHttpCommand implements CliCommandShape {
498
498
  const result = this.killConflict ? await NetUtil.freePortOnConflict(err) : undefined;
499
499
  if (result?.processId) {
500
500
  console.warn('Killed process owning port', result);
501
- process.exit(1);
501
+ process.exitCode = 1; // Indicate error, restart will use if in that mode
502
+ return;
502
503
  }
503
504
  throw err;
504
505
  }
package/bin/trv.js CHANGED
@@ -2,4 +2,4 @@
2
2
  // @ts-check
3
3
  import '@travetto/compiler/bin/hook.js';
4
4
  const { invoke } = await import('@travetto/compiler/support/invoke.ts');
5
- await invoke('exec', ['@travetto/cli/support/entry.trv.js', ...process.argv.slice(2)]);
5
+ await invoke('exec', ['@travetto/cli/support/entry.trv.ts', ...process.argv.slice(2)]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/cli",
3
- "version": "7.1.1",
3
+ "version": "7.1.3",
4
4
  "type": "module",
5
5
  "description": "CLI infrastructure for Travetto framework",
6
6
  "keywords": [
@@ -29,8 +29,8 @@
29
29
  "directory": "module/cli"
30
30
  },
31
31
  "dependencies": {
32
- "@travetto/schema": "^7.1.1",
33
- "@travetto/terminal": "^7.1.1"
32
+ "@travetto/schema": "^7.1.3",
33
+ "@travetto/terminal": "^7.1.3"
34
34
  },
35
35
  "travetto": {
36
36
  "displayName": "Command Line Interface",
package/src/execute.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ConsoleManager, Runtime, ShutdownManager } from '@travetto/runtime';
1
+ import { ConsoleManager, Runtime, ShutdownManager, Util } from '@travetto/runtime';
2
2
 
3
3
  import { HelpUtil } from './help.ts';
4
4
  import { CliCommandRegistryIndex } from './registry/registry-index.ts';
@@ -63,6 +63,9 @@ export class ExecutionManager {
63
63
  */
64
64
  static async run(argv: string[]): Promise<void> {
65
65
  try {
66
+ // Wait 50ms to allow stdout to flush on shutdown
67
+ ShutdownManager.signal.addEventListener('abort', () => Util.blockingTimeout(50));
68
+
66
69
  const { cmd, args, help } = CliParseUtil.getArgs(argv);
67
70
  if (!cmd) {
68
71
  console.info!(await HelpUtil.renderAllHelp());
package/src/util.ts CHANGED
@@ -31,7 +31,7 @@ export class CliUtil {
31
31
  static async runWithRestartOnChange<T extends CliCommandShapeFields>(cmd: T): Promise<void> {
32
32
  if (Env.TRV_RESTART_TARGET.isTrue) {
33
33
  Env.TRV_RESTART_TARGET.clear();
34
- WatchUtil.listenForSignals();
34
+ ShutdownManager.disableInterrupt();
35
35
  return;
36
36
  } else if (cmd.restartOnChange !== true) {
37
37
  return; // Not restarting, run normal
@@ -40,16 +40,18 @@ export class CliUtil {
40
40
  ShutdownManager.disableInterrupt();
41
41
 
42
42
  let child: ChildProcess | undefined;
43
- void WatchUtil.watchCompilerEvents('file', () => child && WatchUtil.triggerSignal(child, 'WATCH_RESTART'));
44
- process.on('SIGINT', () => child && WatchUtil.triggerSignal(child, 'WATCH_SHUTDOWN'));
43
+ void WatchUtil.watchCompilerEvents('file', () => ShutdownManager.shutdownChild(child!, { reason: 'restart', mode: 'exit' }));
44
+ process
45
+ .on('SIGINT', () => ShutdownManager.shutdownChild(child!, { mode: 'exit' }))
46
+ .on('message', msg => child?.send?.(msg!));
45
47
 
46
48
  const env = { ...process.env, ...Env.TRV_RESTART_TARGET.export(true) };
47
49
 
48
50
  await WatchUtil.runWithRetry(
49
51
  async () => {
50
52
  child = spawn(process.argv0, process.argv.slice(1), { env, stdio: ['pipe', 1, 2, 'ipc'] });
51
- const { code } = await ExecUtil.deferToSubprocess(child);
52
- return WatchUtil.exitCodeToResult(code);
53
+ const { code } = await ExecUtil.getResult(child, { catch: true });
54
+ return ShutdownManager.reasonForExitCode(code);
53
55
  },
54
56
  {
55
57
  maxRetries: 5,
@@ -64,8 +66,7 @@ export class CliUtil {
64
66
  }
65
67
  );
66
68
 
67
- await ShutdownManager.shutdown();
68
- process.exit();
69
+ await ShutdownManager.shutdown({ mode: 'exit' });
69
70
  }
70
71
 
71
72
  /**