Skip to content

Commit

Permalink
child_process: refactor to use validateBoolean
Browse files Browse the repository at this point in the history
PR-URL: #38927
Reviewed-By: Antoine du Hamel <[email protected]>
Reviewed-By: Darshan Sen <[email protected]>
Reviewed-By: Khaidi Chu <[email protected]>
Reviewed-By: Zijian Liu <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
Ayase-252 authored and richardlau committed Jul 20, 2021
1 parent 49a0006 commit fc2b1ec
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions lib/child_process.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ const {
validateString,
isInt32,
validateAbortSignal,
validateBoolean,
} = require('internal/validators');
const child_process = require('internal/child_process');
const {
Expand Down Expand Up @@ -463,10 +464,8 @@ function normalizeSpawnArguments(file, args, options) {
}

// Validate detached, if present.
if (options.detached != null &&
typeof options.detached !== 'boolean') {
throw new ERR_INVALID_ARG_TYPE('options.detached',
'boolean', options.detached);
if (options.detached != null) {
validateBoolean(options.detached, 'options.detached');
}

// Validate the uid, if present.
Expand Down Expand Up @@ -494,19 +493,15 @@ function normalizeSpawnArguments(file, args, options) {
}

// Validate windowsHide, if present.
if (options.windowsHide != null &&
typeof options.windowsHide !== 'boolean') {
throw new ERR_INVALID_ARG_TYPE('options.windowsHide',
'boolean', options.windowsHide);
if (options.windowsHide != null) {
validateBoolean(options.windowsHide, 'options.windowsHide');
}

// Validate windowsVerbatimArguments, if present.
let { windowsVerbatimArguments } = options;
if (windowsVerbatimArguments != null &&
typeof windowsVerbatimArguments !== 'boolean') {
throw new ERR_INVALID_ARG_TYPE('options.windowsVerbatimArguments',
'boolean',
windowsVerbatimArguments);
if (windowsVerbatimArguments != null) {
validateBoolean(windowsVerbatimArguments,
'options.windowsVerbatimArguments');
}

if (options.shell) {
Expand Down

0 comments on commit fc2b1ec

Please sign in to comment.