Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

child_process: replace var with let/const #30389

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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