aboutsummaryrefslogtreecommitdiff
path: root/lib/child_process.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/child_process.js')
-rw-r--r--lib/child_process.js55
1 files changed, 28 insertions, 27 deletions
diff --git a/lib/child_process.js b/lib/child_process.js
index 9226d127b3..a7587d0ac5 100644
--- a/lib/child_process.js
+++ b/lib/child_process.js
@@ -22,7 +22,7 @@ function handleWrapGetter(name, callback) {
Object.defineProperty(handleWraps, name, {
get: function() {
- if (!util.isUndefined(cons)) return cons;
+ if (cons !== undefined) return cons;
return cons = callback();
}
});
@@ -295,9 +295,9 @@ function getSocketList(type, slave, key) {
const INTERNAL_PREFIX = 'NODE_';
function handleMessage(target, message, handle) {
var eventName = 'message';
- if (!util.isNull(message) &&
- util.isObject(message) &&
- util.isString(message.cmd) &&
+ if (message !== null &&
+ typeof message === 'object' &&
+ typeof message.cmd === 'string' &&
message.cmd.length > INTERNAL_PREFIX.length &&
message.cmd.slice(0, INTERNAL_PREFIX.length) === INTERNAL_PREFIX) {
eventName = 'internalMessage';
@@ -353,7 +353,7 @@ function setupChannel(target, channel) {
target.on('internalMessage', function(message, handle) {
// Once acknowledged - continue sending handles.
if (message.cmd === 'NODE_HANDLE_ACK') {
- assert(util.isArray(target._handleQueue));
+ assert(Array.isArray(target._handleQueue));
var queue = target._handleQueue;
target._handleQueue = null;
@@ -400,7 +400,7 @@ function setupChannel(target, channel) {
target._send = function(message, handle, swallowErrors) {
assert(this.connected || this._channel);
- if (util.isUndefined(message))
+ if (message === undefined)
throw new TypeError('message cannot be undefined');
// package messages with a handle object
@@ -538,7 +538,7 @@ exports.fork = function(modulePath /*, args, options*/) {
// Get options and args arguments.
var options, args, execArgv;
- if (util.isArray(arguments[1])) {
+ if (Array.isArray(arguments[1])) {
args = arguments[1];
options = util._extend({}, arguments[2]);
} else {
@@ -583,7 +583,7 @@ exports._forkChild = function(fd) {
function normalizeExecArgs(command /*, options, callback */) {
var file, args, options, callback;
- if (util.isFunction(arguments[1])) {
+ if (typeof arguments[1] === 'function') {
options = undefined;
callback = arguments[1];
} else {
@@ -638,11 +638,11 @@ exports.execFile = function(file /* args, options, callback */) {
// Parse the parameters.
- if (util.isFunction(arguments[arguments.length - 1])) {
+ if (typeof arguments[arguments.length - 1] === 'function') {
callback = arguments[arguments.length - 1];
}
- if (util.isArray(arguments[1])) {
+ if (Array.isArray(arguments[1])) {
args = arguments[1];
options = util._extend(options, arguments[2]);
} else {
@@ -806,14 +806,14 @@ function _validateStdio(stdio, sync) {
ipcFd;
// Replace shortcut with an array
- if (util.isString(stdio)) {
+ if (typeof stdio === 'string') {
switch (stdio) {
case 'ignore': stdio = ['ignore', 'ignore', 'ignore']; break;
case 'pipe': stdio = ['pipe', 'pipe', 'pipe']; break;
case 'inherit': stdio = [0, 1, 2]; break;
default: throw new TypeError('Incorrect value of stdio option: ' + stdio);
}
- } else if (!util.isArray(stdio)) {
+ } else if (!Array.isArray(stdio)) {
throw new TypeError('Incorrect value of stdio option: ' +
util.inspect(stdio));
}
@@ -837,13 +837,13 @@ function _validateStdio(stdio, sync) {
}
// Defaults
- if (util.isNullOrUndefined(stdio)) {
+ if (stdio === null || stdio === undefined) {
stdio = i < 3 ? 'pipe' : 'ignore';
}
if (stdio === null || stdio === 'ignore') {
acc.push({type: 'ignore'});
- } else if (stdio === 'pipe' || util.isNumber(stdio) && stdio < 0) {
+ } else if (stdio === 'pipe' || typeof stdio === 'number' && stdio < 0) {
var a = {
type: 'pipe',
readable: i === 0,
@@ -855,7 +855,7 @@ function _validateStdio(stdio, sync) {
acc.push(a);
} else if (stdio === 'ipc') {
- if (sync || !util.isUndefined(ipc)) {
+ if (sync || ipc !== undefined) {
// Cleanup previously created pipes
cleanup();
if (!sync)
@@ -877,7 +877,7 @@ function _validateStdio(stdio, sync) {
type: 'inherit',
fd: i
});
- } else if (util.isNumber(stdio) || util.isNumber(stdio.fd)) {
+ } else if (typeof stdio === 'number' || typeof stdio.fd === 'number') {
acc.push({
type: 'fd',
fd: stdio.fd || stdio
@@ -893,7 +893,7 @@ function _validateStdio(stdio, sync) {
wrapType: getHandleWrapType(handle),
handle: handle
});
- } else if (util.isBuffer(stdio) || util.isString(stdio)) {
+ } else if (stdio instanceof Buffer || typeof stdio === 'string') {
if (!sync) {
cleanup();
throw new TypeError('Asynchronous forks do not support Buffer input: ' +
@@ -919,7 +919,8 @@ function normalizeSpawnArguments(file /*, args, options*/) {
if (Array.isArray(arguments[1])) {
args = arguments[1].slice(0);
options = arguments[2];
- } else if (arguments[1] !== undefined && !util.isObject(arguments[1])) {
+ } else if (arguments[1] !== undefined &&
+ (arguments[1] === null || typeof arguments[1] !== 'object')) {
throw new TypeError('Incorrect value of args option');
} else {
args = [];
@@ -928,7 +929,7 @@ function normalizeSpawnArguments(file /*, args, options*/) {
if (options === undefined)
options = {};
- else if (!util.isObject(options))
+ else if (options === null || typeof options !== 'object')
throw new TypeError('options argument must be an object');
options = util._extend({}, options);
@@ -1089,7 +1090,7 @@ ChildProcess.prototype.spawn = function(options) {
ipcFd = stdio.ipcFd;
stdio = options.stdio = stdio.stdio;
- if (!util.isUndefined(ipc)) {
+ if (ipc !== undefined) {
// Let child process know about opened IPC channel
options.envPairs = options.envPairs || [];
options.envPairs.push('NODE_CHANNEL_FD=' + ipcFd);
@@ -1150,19 +1151,19 @@ ChildProcess.prototype.spawn = function(options) {
}
});
- this.stdin = stdio.length >= 1 && !util.isUndefined(stdio[0].socket) ?
+ this.stdin = stdio.length >= 1 && stdio[0].socket !== undefined ?
stdio[0].socket : null;
- this.stdout = stdio.length >= 2 && !util.isUndefined(stdio[1].socket) ?
+ this.stdout = stdio.length >= 2 && stdio[1].socket !== undefined ?
stdio[1].socket : null;
- this.stderr = stdio.length >= 3 && !util.isUndefined(stdio[2].socket) ?
+ this.stderr = stdio.length >= 3 && stdio[2].socket !== undefined ?
stdio[2].socket : null;
this.stdio = stdio.map(function(stdio) {
- return util.isUndefined(stdio.socket) ? null : stdio.socket;
+ return stdio.socket === undefined ? null : stdio.socket;
});
// Add .send() method and start listening for IPC data
- if (!util.isUndefined(ipc)) setupChannel(this, ipc);
+ if (ipc !== undefined) setupChannel(this, ipc);
return err;
};
@@ -1183,7 +1184,7 @@ ChildProcess.prototype.kill = function(sig) {
signal = constants[sig];
}
- if (util.isUndefined(signal)) {
+ if (signal === undefined) {
throw new Error('Unknown signal: ' + sig);
}
@@ -1262,7 +1263,7 @@ function spawnSync(/*file, args, options*/) {
var pipe = options.stdio[i] = util._extend({}, options.stdio[i]);
if (Buffer.isBuffer(input))
pipe.input = input;
- else if (util.isString(input))
+ else if (typeof input === 'string')
pipe.input = new Buffer(input, options.encoding);
else
throw new TypeError(util.format(