Browse Source

child_process: refactor normalizeSpawnArguments()

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 <vsemozhetbyt@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
v6
Rich Trott 8 years ago
parent
commit
6d090e1094
  1. 8
      lib/child_process.js

8
lib/child_process.js

@ -440,9 +440,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')

Loading…
Cancel
Save