Skip to content

Commit 9c33e4b

Browse files
VoltrexKeyvatargos
authored andcommitted
lib: use validator
Used the `validateArray()` validator for array validation for consistency. (Refs: #39536) PR-URL: #39547 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com>
1 parent 5b11042 commit 9c33e4b

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

lib/internal/child_process.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ const {
2222
ERR_MISSING_ARGS
2323
}
2424
} = require('internal/errors');
25-
const { validateString, validateOneOf } = require('internal/validators');
25+
const {
26+
validateArray,
27+
validateOneOf,
28+
validateString,
29+
} = require('internal/validators');
2630
const EventEmitter = require('events');
2731
const net = require('net');
2832
const dgram = require('dgram');
@@ -356,11 +360,8 @@ ChildProcess.prototype.spawn = function(options) {
356360
// Let child process know about opened IPC channel
357361
if (options.envPairs === undefined)
358362
options.envPairs = [];
359-
else if (!ArrayIsArray(options.envPairs)) {
360-
throw new ERR_INVALID_ARG_TYPE('options.envPairs',
361-
'Array',
362-
options.envPairs);
363-
}
363+
else
364+
validateArray(options.envPairs, 'options.envPairs');
364365

365366
options.envPairs.push(`NODE_CHANNEL_FD=${ipcFd}`);
366367
options.envPairs.push(`NODE_CHANNEL_SERIALIZATION_MODE=${serialization}`);

0 commit comments

Comments
 (0)