Skip to content

Commit 908a92f

Browse files
committed
fix: preserve wrapped cli exit status
1 parent c16f303 commit 908a92f

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

bin/cli

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ function main() {
180180
// Invoke the command in a sub-process:
181181
proc = spawn( 'node', subargs, opts );
182182
proc.on( 'error', onError );
183+
proc.on( 'close', onClose );
183184

184185
/**
185186
* Callback invoked upon encountering an error while running a command.
@@ -190,6 +191,21 @@ function main() {
190191
function onError( error ) {
191192
cli.error( error );
192193
}
194+
195+
/**
196+
* Callback invoked upon command exit.
197+
*
198+
* @private
199+
* @param {integer} code - exit code
200+
* @param {(string|null)} signal - exit signal
201+
*/
202+
function onClose( code, signal ) {
203+
if ( signal ) {
204+
process.kill( process.pid, signal );
205+
return;
206+
}
207+
process.exit( code || 0 );
208+
}
193209
}
194210

195211
main();

0 commit comments

Comments
 (0)