From 096080b69ca48c6360b631f68b0413e99f789263 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sun, 9 Jul 2017 13:03:17 -0700 Subject: [PATCH] child_process: refactor normalizeSpawnArguments() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Code is not in hot path. Refactor ternary to be more readable if/else block that mirrors analogous code elsewhere in the function. Change string concatenation to template literal. PR-URL: https://github.com/nodejs/node/pull/14149 Reviewed-By: Vse Mozhet Byt Reviewed-By: Luigi Pinca Reviewed-By: Michaƫl Zasso Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Refael Ackermann --- lib/child_process.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/child_process.js b/lib/child_process.js index 3c907469bf496f..1e0dce854968b8 100644 --- a/lib/child_process.js +++ b/lib/child_process.js @@ -442,9 +442,11 @@ function normalizeSpawnArguments(file, args, options) { const command = [file].concat(args).join(' '); if (process.platform === 'win32') { - file = typeof options.shell === 'string' ? options.shell : - process.env.comspec || 'cmd.exe'; - args = ['/d', '/s', '/c', '"' + command + '"']; + if (typeof options.shell === 'string') + file = options.shell; + else + file = process.env.comspec || 'cmd.exe'; + args = ['/d', '/s', '/c', `"${command}"`]; options.windowsVerbatimArguments = true; } else { if (typeof options.shell === 'string')