Skip to content
Permalink
Browse files

child_process: replace var with let/const

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 MylesBorins committed Nov 12, 2019
1 parent a6625dd commit 8d3e0230614411b1f896728dc1b02a1cc034de70
Showing with 20 additions and 20 deletions.
  1. +20 −20 lib/child_process.js
@@ -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++];
}
@@ -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;
@@ -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 &&
@@ -580,15 +580,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') {
@@ -609,11 +609,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()}`;

0 comments on commit 8d3e023

Please sign in to comment.
You can’t perform that action at this time.