From 8ca5dcbb969a6f400c2c8022178d3252edab16b2 Mon Sep 17 00:00:00 2001 From: ehmicky Date: Tue, 14 May 2019 08:20:21 -0700 Subject: [PATCH] Small refactoring of joinCommand() (#244) --- index.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) 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) => {