Skip to content

Commit

Permalink
Fix sshExec() errors not displaying (#9743)
Browse files Browse the repository at this point in the history
Co-authored-by: Tobbe Lundberg <[email protected]>
  • Loading branch information
Mirai-Miki and Tobbe authored Dec 22, 2023
1 parent 8352f75 commit 751214b
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions packages/cli/src/commands/deploy/baremetal.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down

0 comments on commit 751214b

Please sign in to comment.