Skip to content

Commit

Permalink
lib: use validator
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
VoltrexKeyva authored and targos committed Sep 4, 2021
1 parent 5b11042 commit 9c33e4b
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions lib/internal/child_process.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ const {
ERR_MISSING_ARGS
}
} = require('internal/errors');
const { validateString, validateOneOf } = require('internal/validators');
const {
validateArray,
validateOneOf,
validateString,
} = require('internal/validators');
const EventEmitter = require('events');
const net = require('net');
const dgram = require('dgram');
Expand Down Expand Up @@ -356,11 +360,8 @@ ChildProcess.prototype.spawn = function(options) {
// Let child process know about opened IPC channel
if (options.envPairs === undefined)
options.envPairs = [];
else if (!ArrayIsArray(options.envPairs)) {
throw new ERR_INVALID_ARG_TYPE('options.envPairs',
'Array',
options.envPairs);
}
else
validateArray(options.envPairs, 'options.envPairs');

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

0 comments on commit 9c33e4b

Please sign in to comment.