@stacksjs/cli 0.59.10 → 0.59.11

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/dist/index.js CHANGED
@@ -37,9 +37,8 @@ async function exec(command, options) {
37
37
  stderr: options?.silent || options?.quiet ? "ignore" : options?.stderr || "inherit",
38
38
  detached: options?.background || false,
39
39
  cwd: options?.cwd || import.meta.dir,
40
- onExit(_subprocess, exitCode, _signalCode, _error) {
41
- if (exitCode && exitCode !== ExitCode.Success)
42
- process2.exit(exitCode);
40
+ onExit(subprocess, exitCode, signalCode, error) {
41
+ exitHandler("spawn", subprocess, exitCode, signalCode, error);
43
42
  }
44
43
  });
45
44
  if (options?.stdin === "pipe" && options.input) {
@@ -67,13 +66,24 @@ async function execSync(command, options) {
67
66
  stdout: options?.stdout ?? "pipe",
68
67
  stderr: options?.stderr ?? "inherit",
69
68
  cwd: options?.cwd ?? import.meta.dir,
70
- onExit(_subprocess, exitCode, _signalCode, _error) {
71
- if (exitCode !== ExitCode.Success && exitCode)
72
- process2.exit(exitCode);
69
+ onExit(subprocess, exitCode, signalCode, error) {
70
+ exitHandler("spawnSync", subprocess, exitCode, signalCode, error);
73
71
  }
74
72
  });
75
73
  return proc.stdout.toString();
76
74
  }
75
+ var exitHandler = function(type, subprocess, exitCode, signalCode, error) {
76
+ log2.debug(`exitHandler: ${type}`);
77
+ log2.debug("subprocess", subprocess);
78
+ log2.debug("exitCode", exitCode);
79
+ log2.debug("signalCode", signalCode);
80
+ if (error) {
81
+ log2.error(error);
82
+ process2.exit(ExitCode.FatalError);
83
+ }
84
+ if (exitCode !== ExitCode.Success && exitCode)
85
+ process2.exit(exitCode);
86
+ };
77
87
 
78
88
  // src/utils.ts
79
89
  import {collect} from "@stacksjs/collections";
@@ -520,7 +530,7 @@ import {log as log3} from "@stacksjs/logging";
520
530
  import {ExitCode as ExitCode2} from "@stacksjs/types";
521
531
  import {bgCyan as bgCyan2, bold as bold2, cyan as cyan2, dim as dim2, gray as gray2, green as green2, italic as italic2} from "kolorist";
522
532
  // package.json
523
- var version = "0.59.10";
533
+ var version = "0.59.11";
524
534
 
525
535
  // src/helpers.ts
526
536
  async function intro(command2, options) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/cli",
3
3
  "type": "module",
4
- "version": "0.59.10",
4
+ "version": "0.59.11",
5
5
  "description": "TypeScript framework for CLI artisans. Build beautiful console apps with ease.",
6
6
  "author": "Chris Breuer",
7
7
  "license": "MIT",
package/src/exec.ts CHANGED
@@ -43,9 +43,8 @@ export async function exec(command: string | string[], options?: CliOptions): Pr
43
43
  detached: options?.background || false,
44
44
  cwd: options?.cwd || import.meta.dir,
45
45
  // env: { ...e, ...options?.env },
46
- onExit(_subprocess, exitCode, _signalCode, _error) {
47
- if (exitCode && exitCode !== ExitCode.Success)
48
- process.exit(exitCode)
46
+ onExit(subprocess, exitCode, signalCode, error) {
47
+ exitHandler('spawn', subprocess, exitCode, signalCode, error)
49
48
  },
50
49
  })
51
50
 
@@ -103,12 +102,26 @@ export async function execSync(command: string | string[], options?: CliOptions)
103
102
  stderr: options?.stderr ?? 'inherit',
104
103
  cwd: options?.cwd ?? import.meta.dir,
105
104
  // env: { ...Bun.env, ...options?.env },
106
- onExit(_subprocess, exitCode, _signalCode, _error) {
107
- // console.log('onExit', { subprocess, exitCode, signalCode, error })
108
- if (exitCode !== ExitCode.Success && exitCode)
109
- process.exit(exitCode)
105
+ onExit(subprocess, exitCode, signalCode, error) {
106
+ exitHandler('spawnSync', subprocess, exitCode, signalCode, error)
110
107
  },
111
108
  })
112
109
 
113
110
  return proc.stdout.toString()
114
111
  }
112
+
113
+ // @ts-expect-error - missing types is okay here but can be improved later on
114
+ function exitHandler(type: 'spawn' | 'spawnSync', subprocess, exitCode, signalCode, error) {
115
+ log.debug(`exitHandler: ${type}`)
116
+ log.debug('subprocess', subprocess)
117
+ log.debug('exitCode', exitCode)
118
+ log.debug('signalCode', signalCode)
119
+
120
+ if (error) {
121
+ log.error(error)
122
+ process.exit(ExitCode.FatalError)
123
+ }
124
+
125
+ if (exitCode !== ExitCode.Success && exitCode)
126
+ process.exit(exitCode)
127
+ }