Return-Path: X-Original-To: apmail-cordova-commits-archive@www.apache.org Delivered-To: apmail-cordova-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 67CF610409 for ; Wed, 2 Apr 2014 12:41:03 +0000 (UTC) Received: (qmail 62046 invoked by uid 500); 2 Apr 2014 12:41:03 -0000 Delivered-To: apmail-cordova-commits-archive@cordova.apache.org Received: (qmail 61946 invoked by uid 500); 2 Apr 2014 12:40:56 -0000 Mailing-List: contact commits-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cordova.apache.org Delivered-To: mailing list commits@cordova.apache.org Received: (qmail 61036 invoked by uid 99); 2 Apr 2014 12:40:53 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Apr 2014 12:40:53 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 458C98AF294; Wed, 2 Apr 2014 12:40:53 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: agrieve@apache.org To: commits@cordova.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: git commit: CB-6377 Fix up superspawn's cmd fallback when there is a space in the args Date: Wed, 2 Apr 2014 12:40:53 +0000 (UTC) Repository: cordova-cli Updated Branches: refs/heads/master 4603622f2 -> 290a2a1c9 CB-6377 Fix up superspawn's cmd fallback when there is a space in the args Tested this by executing: echo a "b b" Project: http://git-wip-us.apache.org/repos/asf/cordova-cli/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-cli/commit/290a2a1c Tree: http://git-wip-us.apache.org/repos/asf/cordova-cli/tree/290a2a1c Diff: http://git-wip-us.apache.org/repos/asf/cordova-cli/diff/290a2a1c Branch: refs/heads/master Commit: 290a2a1c925d952b2e376ba0edc88fd6809bdd20 Parents: 4603622 Author: Andrew Grieve Authored: Wed Apr 2 08:38:35 2014 -0400 Committer: Andrew Grieve Committed: Wed Apr 2 08:38:35 2014 -0400 ---------------------------------------------------------------------- src/superspawn.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/290a2a1c/src/superspawn.js ---------------------------------------------------------------------- diff --git a/src/superspawn.js b/src/superspawn.js index 59f36de..c277aea 100644 --- a/src/superspawn.js +++ b/src/superspawn.js @@ -46,6 +46,13 @@ function resolveWindowsExe(cmd) { return cmd; } +function maybeQuote(a) { + if (a.indexOf(' ') != -1) { + a = '"' + a + '"'; + } + return a; +} + // opts: // printCommand: Whether to log the command (default: false) // stdio: 'default' is to capture output and returning it as a string to success (same as exec) @@ -66,7 +73,7 @@ exports.spawn = function(cmd, args, opts) { // but for things like "del", cmd will do the trick. if (!fs.existsSync(cmd)) { // We need to use /s to ensure that spaces are parsed properly with cmd spawned content - args = [['/s', '/c', '"'+[cmd].concat(args).map(function(a){if (/^[^"].* .*[^"]/.test(a)) return '"'+a+'"'; return a;}).join(" ")+'"'].join(" ")]; + args = ['/s', '/c', cmd].concat(args); cmd = 'cmd'; } } @@ -83,7 +90,7 @@ exports.spawn = function(cmd, args, opts) { spawnOpts.env = _.extend(_.extend({}, process.env), opts.env); } - events.emit(opts.printCommand ? 'log' : 'verbose', 'Running command: ' + cmd + ' ' + args.join(" ")); + events.emit(opts.printCommand ? 'log' : 'verbose', 'Running command: ' + maybeQuote(cmd) + ' ' + args.map(maybeQuote).join(' ')); var child = child_process.spawn(cmd, args, spawnOpts); var capturedOut = '';