From 8d3e0230614411b1f896728dc1b02a1cc034de70 Mon Sep 17 00:00:00 2001 From: dnlup Date: Tue, 12 Nov 2019 16:12:24 +0100 Subject: [PATCH] child_process: replace var with let/const PR-URL: https://github.com/nodejs/node/pull/30389 Reviewed-By: James M Snell Reviewed-By: David Carlier Reviewed-By: Gireesh Punathil Reviewed-By: Ruben Bridgewater Reviewed-By: Trivikram Kamat --- lib/child_process.js | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/lib/child_process.js b/lib/child_process.js index 43257e53dfe031..42b04bb9b06293 100644 --- a/lib/child_process.js +++ b/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,7 +231,7 @@ 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)) { @@ -239,15 +239,15 @@ function execFile(file /* , args, options, callback */) { } 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()}`;