Skip to content

Commit 208bc81

Browse files
hotpineapplerichardlau
authored andcommitted
child_process: remove unsafe array iteration
PR-URL: #59347 Reviewed-By: Antoine du Hamel <[email protected]>
1 parent a2d2003 commit 208bc81

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/child_process.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,8 @@ function normalizeSpawnArguments(file, args, options) {
639639

640640
if (options.shell) {
641641
validateArgumentNullCheck(options.shell, 'options.shell');
642-
const command = ArrayPrototypeJoin([file, ...args], ' ');
642+
643+
const command = args.length > 0 ? `${file} ${ArrayPrototypeJoin(args, ' ')}` : file;
643644
// Set the shell, switches, and commands.
644645
if (process.platform === 'win32') {
645646
if (typeof options.shell === 'string')

0 commit comments

Comments
 (0)