From d611d7c00e8658fb40ae6c318ac725c7ee9ede49 Mon Sep 17 00:00:00 2001 From: Josh GM Walker <56300765+Josh-Walker-GM@users.noreply.github.com> Date: Wed, 22 May 2024 00:18:18 +0100 Subject: [PATCH] fix(cli): Handle case for no arguments for verbose baremetal deploy (#10663) **Problem** We recently improved the verbose output of the baremetal deployment process. It looks like this improvement has introduced a small bug. See #10654 for more details. **Changes** 1. Guard against `args` being undefined. --------- Co-authored-by: Tobbe Lundberg --- .changesets/10663.md | 4 ++++ .../cli/src/commands/deploy/baremetal/SshExecutor.js | 11 ++++------- 2 files changed, 8 insertions(+), 7 deletions(-) create mode 100644 .changesets/10663.md diff --git a/.changesets/10663.md b/.changesets/10663.md new file mode 100644 index 000000000000..3173cf56cb10 --- /dev/null +++ b/.changesets/10663.md @@ -0,0 +1,4 @@ +- fix(cli): Handle case for no arguments for verbose baremetal deploy (#10663) by @Josh-Walker-GM + +The change corrects a bug during baremetal deployments when using the `--verbose` flag. See #10654 for more details. + diff --git a/packages/cli/src/commands/deploy/baremetal/SshExecutor.js b/packages/cli/src/commands/deploy/baremetal/SshExecutor.js index 4978a930dbf3..aa1090848cdb 100644 --- a/packages/cli/src/commands/deploy/baremetal/SshExecutor.js +++ b/packages/cli/src/commands/deploy/baremetal/SshExecutor.js @@ -10,15 +10,12 @@ export class SshExecutor { * the exit code with the same code returned from the SSH command. */ async exec(path, command, args) { - let sshCommand = command - - if (args) { - sshCommand += ` ${args.join(' ')}` - } + const argsString = args?.join(' ') || '' + const sshCommand = command + argsString if (this.verbose) { console.log( - `SshExecutor::exec running command \`${command} ${args.join(' ')}\` in ${path}`, + `SshExecutor::exec running command \`${sshCommand}\` in ${path}`, ) } @@ -28,7 +25,7 @@ export class SshExecutor { if (result.code !== 0) { const error = new Error( - `Error while running command \`${command} ${args.join(' ')}\` in ${path}\n` + + `Error while running command \`${sshCommand}\` in ${path}\n` + result.stderr, ) error.exitCode = result.code