From 751214b7d9f48d6ec03c1a46ef98a89d606ff9d4 Mon Sep 17 00:00:00 2001 From: Michael Bossner Date: Sat, 23 Dec 2023 02:45:33 +1000 Subject: [PATCH] Fix sshExec() errors not displaying (#9743) Co-authored-by: Tobbe Lundberg --- packages/cli/src/commands/deploy/baremetal.js | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/packages/cli/src/commands/deploy/baremetal.js b/packages/cli/src/commands/deploy/baremetal.js index 316aa6d4f1cd..bc969e542e6a 100644 --- a/packages/cli/src/commands/deploy/baremetal.js +++ b/packages/cli/src/commands/deploy/baremetal.js @@ -131,8 +131,8 @@ export const builder = (yargs) => { ) } -// Executes a single command via SSH connection. Displays an error and will -// exit() with the same code returned from the SSH command. +// Executes a single command via SSH connection. Throws an error and sets +// the exit code with the same code returned from the SSH command. const sshExec = async (ssh, path, command, args) => { let sshCommand = command @@ -145,18 +145,11 @@ const sshExec = async (ssh, path, command, args) => { }) if (result.code !== 0) { - console.error(c.error(`\nDeploy failed!`)) - console.error( - c.error(`Error while running command \`${command} ${args.join(' ')}\`:`) - ) - console.error( - boxen(result.stderr, { - padding: { top: 0, bottom: 0, right: 1, left: 1 }, - margin: 0, - borderColor: 'red', - }) + const error = new Error( + `Error while running command \`${command} ${args.join(' ')}\`` ) - process.exit(result.code) + error.exitCode = result.code + throw error } return result