diff --git a/index.js b/index.js index c0c1dd6066..fe6b9e8765 100644 --- a/index.js +++ b/index.js @@ -231,14 +231,12 @@ function getErrorPrefix({timedOut, timeout, signal, exitCodeName, exitCode, isCa return `failed with exit code ${exitCode} (${exitCodeName})`; } -function joinCommand(command, args) { - let joinedCommand = command; - - if (Array.isArray(args) && args.length > 0) { - joinedCommand += ' ' + args.join(' '); +function joinCommand(command, args = []) { + if (!Array.isArray(args)) { + return command; } - return joinedCommand; + return [command, ...args].join(' '); } const execa = (command, args, options) => {