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 <duhamelantoine1995@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Khaidi Chu <i@2333.moe>
Reviewed-By: Zijian Liu <lxxyxzj@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
Ayase-252 authored and targos committed Jun 11, 2021
1 parent 651c58b commit e87cd45
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 @@ -75,6 +75,7 @@ const { getValidatedPath } = require('internal/fs/utils');
const {
isInt32,
validateAbortSignal,
validateBoolean,
validateObject,
validateString,
} = require('internal/validators');
Expand Down Expand Up @@ -459,10 +460,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 All @@ -489,19 +488,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 e87cd45

Please sign in to comment.