Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix sshExec() errors not displaying #9743

Merged
merged 3 commits into from
Dec 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading