Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions bin/cli
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ function main() {
// Invoke the command in a sub-process:
proc = spawn( 'node', subargs, opts );
proc.on( 'error', onError );
proc.on( 'close', onClose );

/**
* Callback invoked upon encountering an error while running a command.
Expand All @@ -190,6 +191,21 @@ function main() {
function onError( error ) {
cli.error( error );
}

/**
* Callback invoked upon command exit.
*
* @private
* @param {integer} code - exit code
* @param {(string|null)} signal - exit signal
*/
function onClose( code, signal ) {
if ( signal ) {
process.kill( process.pid, signal );
return;
}
process.exit( code || 0 );
}
}

main();
Loading