From 908a92f4b6084e7bf939523956243bf674d9450b Mon Sep 17 00:00:00 2001 From: saschabuehrle Date: Sat, 4 Apr 2026 10:35:41 +0200 Subject: [PATCH] fix: preserve wrapped cli exit status --- bin/cli | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/bin/cli b/bin/cli index 94eec1fb40b5..42422f8da800 100644 --- a/bin/cli +++ b/bin/cli @@ -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. @@ -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();