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 <[email protected]>
Reviewed-By: David Carlier <[email protected]>
Reviewed-By: Gireesh Punathil <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
  • Loading branch information
dnlup authored and targos committed Dec 1, 2019
1 parent a353179 commit a7a71d4
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 @@ -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') {
Expand All @@ -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()}`;
Expand Down

0 comments on commit a7a71d4

Please sign in to comment.