|
| 1 | +import process from 'node:process' |
1 | 2 | import { ExitCode } from '@stacksjs/types'
|
2 | 3 | import type { CliOptions, StacksError, Subprocess, SyncSubprocess } from '@stacksjs/types'
|
3 | 4 | import { type Result, err, handleError, ok } from '@stacksjs/error-handling'
|
@@ -30,11 +31,11 @@ export async function exec(command: string | string[], options?: CliOptions): Pr
|
30 | 31 | stdout: options?.stdout || 'inherit',
|
31 | 32 | stderr: options?.stderr || 'inherit',
|
32 | 33 | cwd: options?.cwd || import.meta.dir,
|
33 |
| - // onExit(subprocess, exitCode, signalCode, error) { |
34 |
| - // console.log('onExit', { subprocess, exitCode, signalCode, error }) |
35 |
| - // // if (exitCode !== ExitCode.Success && exitCode) |
36 |
| - // // handleError(`Failed to execute command: ${cmd.join(' ')}`) |
37 |
| - // }, |
| 34 | + onExit(subprocess, exitCode, signalCode, error) { |
| 35 | + // console.log('onExit', { subprocess, exitCode, signalCode, error }) |
| 36 | + if (exitCode !== ExitCode.Success && exitCode) |
| 37 | + process.exit(exitCode) |
| 38 | + }, |
38 | 39 | })
|
39 | 40 |
|
40 | 41 | const exited = await proc.exited
|
@@ -71,10 +72,11 @@ export function execSync(command: string | string[], options?: CliOptions): Resu
|
71 | 72 | stderr: options?.stderr ?? 'inherit',
|
72 | 73 | cwd: options?.cwd ?? import.meta.dir,
|
73 | 74 | // env: { ...Bun.env, ...options?.env },
|
74 |
| - // onExit(subprocess: any, exitCode: any, signalCode: any, error: any) { |
75 |
| - // if (exitCode !== ExitCode.Success) |
76 |
| - // log.error(error) |
77 |
| - // }, |
| 75 | + onExit(subprocess, exitCode, signalCode, error) { |
| 76 | + // console.log('onExit', { subprocess, exitCode, signalCode, error }) |
| 77 | + if (exitCode !== ExitCode.Success && exitCode) |
| 78 | + process.exit(exitCode) |
| 79 | + }, |
78 | 80 | })
|
79 | 81 |
|
80 | 82 | if (proc.success)
|
|
0 commit comments