From 2222c845c625fb2067199c74d973d0ea6de443f7 Mon Sep 17 00:00:00 2001 From: Neal Beeken Date: Thu, 23 May 2024 10:39:29 -0400 Subject: [PATCH] chore: errexit --- .github/scripts/libmongocrypt.mjs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/scripts/libmongocrypt.mjs b/.github/scripts/libmongocrypt.mjs index 7782ea6..d30d071 100644 --- a/.github/scripts/libmongocrypt.mjs +++ b/.github/scripts/libmongocrypt.mjs @@ -56,11 +56,16 @@ async function parseArguments() { /** `xtrace` style command runner, uses spawn so that stdio is inherited */ async function run(command, args = [], options = {}) { - console.error(`+ ${command} ${args.join(' ')}`, options.cwd ? `(in: ${options.cwd})` : ''); - await events.once( - child_process.spawn(command, args, { stdio: 'inherit', cwd: resolveRoot('.'), ...options }), - 'exit' - ); + const commandDetails = `+ ${command} ${args.join(' ')}${options.cwd ? ` (in: ${options.cwd})` : ''}`; + console.error(commandDetails); + const proc = child_process.spawn(command, args, { + stdio: 'inherit', + cwd: resolveRoot('.'), + ...options + }); + await events.once(proc, 'exit'); + + if (proc.exitCode != 0) throw new Error(`CRASH(${proc.exitCode}): ${commandDetails}`); } /** CLI flag maker: `toFlags({a: 1, b: 2})` yields `['-a=1', '-b=2']` */