Skip to content

Commit 6d090e1

Browse files
committed
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: #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>
1 parent 7f26a29 commit 6d090e1

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

‎lib/child_process.js‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -440,9 +440,11 @@ function normalizeSpawnArguments(file, args, options) {
440440
const command = [file].concat(args).join(' ');
441441

442442
if (process.platform === 'win32') {
443-
file = typeof options.shell === 'string' ? options.shell :
444-
process.env.comspec || 'cmd.exe';
445-
args = ['/d', '/s', '/c', '"' + command + '"'];
443+
if (typeof options.shell === 'string')
444+
file = options.shell;
445+
else
446+
file = process.env.comspec || 'cmd.exe';
447+
args = ['/d', '/s', '/c', `"${command}"`];
446448
options.windowsVerbatimArguments = true;
447449
} else {
448450
if (typeof options.shell === 'string')

0 commit comments

Comments
 (0)