From 3623af0887df855c0e50f8b1169c4abd3b9d255e Mon Sep 17 00:00:00 2001 From: Basit <1305718+mabaasit@users.noreply.github.com> Date: Tue, 13 Aug 2024 15:10:27 +0200 Subject: [PATCH] fix(build): throw error when build fails (#6108) init var with a different name --- packages/hadron-build/lib/run.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/hadron-build/lib/run.js b/packages/hadron-build/lib/run.js index 91af98e2644..303cbc73c08 100644 --- a/packages/hadron-build/lib/run.js +++ b/packages/hadron-build/lib/run.js @@ -55,13 +55,13 @@ function run(cmd, args, opts, fn) { }); proc.on('exit', function(code) { + const _output = Buffer.concat(output).toString('utf-8'); if (code !== 0) { - const output = Buffer.concat(output).toString('utf-8'); - debug('command failed!', { cmd, output }); + debug('command failed!', { cmd, output: _output }); const error = new Error(`Command failed with exit code ${code}: ${cmd} ${args.join(' ')} [enable line-by-line output via 'DEBUG=hadron*']`); error.output = { - output, - [util.inspect.custom]() { return util.inspect(output, { maxStringLength: Infinity }); } + output: _output, + [util.inspect.custom]() { return util.inspect(_output, { maxStringLength: Infinity }); } }; fn(error); return; @@ -70,7 +70,7 @@ function run(cmd, args, opts, fn) { cmd: cmd }); - fn(null, Buffer.concat(output).toString('utf-8')); + fn(null, _output); }); }