Skip to content

Commit

Permalink
child_process: replace var with let/const
Browse files Browse the repository at this point in the history
PR-URL: #30389
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
  • Loading branch information
dnlup authored and addaleax committed Nov 30, 2019
1 parent 3796885 commit dae36a9
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions lib/child_process.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ function fork(modulePath /* , args, options */) {
validateString(modulePath, 'modulePath');

// Get options and args arguments.
var execArgv;
var options = {};
var args = [];
var pos = 1;
let execArgv;
let options = {};
let args = [];
let pos = 1;
if (pos < arguments.length && Array.isArray(arguments[pos])) {
args = arguments[pos++];
}
Expand Down Expand Up @@ -231,23 +231,23 @@ function execFile(file /* , args, options, callback */) {
windowsVerbatimArguments: !!options.windowsVerbatimArguments
});

var encoding;
let encoding;
const _stdout = [];
const _stderr = [];
if (options.encoding !== 'buffer' && Buffer.isEncoding(options.encoding)) {
encoding = options.encoding;
} else {
encoding = null;
}
var stdoutLen = 0;
var stderrLen = 0;
var killed = false;
var exited = false;
var timeoutId;
let stdoutLen = 0;
let stderrLen = 0;
let killed = false;
let exited = false;
let timeoutId;

var ex = null;
let ex = null;

var cmd = file;
let cmd = file;

function exithandler(code, signal) {
if (exited) return;
Expand All @@ -261,8 +261,8 @@ function execFile(file /* , args, options, callback */) {
if (!callback) return;

// merge chunks
var stdout;
var stderr;
let stdout;
let stderr;
if (encoding ||
(
child.stdout &&
Expand Down Expand Up @@ -562,15 +562,15 @@ function spawnSync(file, args, options) {
options.stdio = getValidStdio(options.stdio || 'pipe', true).stdio;

if (options.input) {
var stdin = options.stdio[0] = { ...options.stdio[0] };
const stdin = options.stdio[0] = { ...options.stdio[0] };
stdin.input = options.input;
}

// We may want to pass data in on any given fd, ensure it is a valid buffer
for (var i = 0; i < options.stdio.length; i++) {
var input = options.stdio[i] && options.stdio[i].input;
for (let i = 0; i < options.stdio.length; i++) {
const input = options.stdio[i] && options.stdio[i].input;
if (input != null) {
var pipe = options.stdio[i] = { ...options.stdio[i] };
const pipe = options.stdio[i] = { ...options.stdio[i] };
if (isArrayBufferView(input)) {
pipe.input = input;
} else if (typeof input === 'string') {
Expand All @@ -591,11 +591,11 @@ function spawnSync(file, args, options) {


function checkExecSyncError(ret, args, cmd) {
var err;
let err;
if (ret.error) {
err = ret.error;
} else if (ret.status !== 0) {
var msg = 'Command failed: ';
let msg = 'Command failed: ';
msg += cmd || args.join(' ');
if (ret.stderr && ret.stderr.length > 0)
msg += `\n${ret.stderr.toString()}`;
Expand Down

0 comments on commit dae36a9

Please sign in to comment.