From 8709b905833d2078eaeec65a5e6dbce16096ae00 Mon Sep 17 00:00:00 2001 From: Luis Camargo Date: Tue, 12 Nov 2019 15:28:55 +0000 Subject: child_process: replace var with const/let in internal/child_process.js PR-URL: https://github.com/nodejs/node/pull/30414 Reviewed-By: James M Snell Reviewed-By: Trivikram Kamat Reviewed-By: Ruben Bridgewater Reviewed-By: Gireesh Punathil --- lib/internal/child_process.js | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/lib/internal/child_process.js b/lib/internal/child_process.js index 9e13650fa3..2d4aff982b 100644 --- a/lib/internal/child_process.js +++ b/lib/internal/child_process.js @@ -103,8 +103,8 @@ const handleConversion = { // The worker should keep track of the socket message.key = socket.server._connectionKey; - var firstTime = !this.channel.sockets.send[message.key]; - var socketList = getSocketList('send', this, message.key); + const firstTime = !this.channel.sockets.send[message.key]; + const socketList = getSocketList('send', this, message.key); // The server should no longer expose a .connection property // and when asked to close it should query the socket status from @@ -171,7 +171,7 @@ const handleConversion = { if (message.key) { // Add socket to connections list - var socketList = getSocketList('got', this, message.key); + const socketList = getSocketList('got', this, message.key); socketList.add({ socket: socket }); @@ -258,7 +258,7 @@ function ChildProcess() { this._handle = null; if (exitCode < 0) { - var syscall = this.spawnfile ? 'spawn ' + this.spawnfile : 'spawn'; + const syscall = this.spawnfile ? 'spawn ' + this.spawnfile : 'spawn'; const err = errnoException(exitCode, syscall); if (this.spawnfile) @@ -290,7 +290,7 @@ function flushStdio(subprocess) { if (stdio == null) return; - for (var i = 0; i < stdio.length; i++) { + for (let i = 0; i < stdio.length; i++) { const stream = stdio[i]; // TODO(addaleax): This doesn't necessarily account for all the ways in // which data can be read from a stream, e.g. being consumed on the @@ -471,7 +471,7 @@ ChildProcess.prototype.kill = function(sig) { convertToValidSignal(sig === undefined ? 'SIGTERM' : sig); if (this._handle) { - var err = this._handle.kill(signal); + const err = this._handle.kill(signal); if (err === 0) { /* Success. */ this.killed = true; @@ -611,7 +611,7 @@ function setupChannel(target, channel, serializationMode) { } assert(Array.isArray(target._handleQueue)); - var queue = target._handleQueue; + const queue = target._handleQueue; target._handleQueue = null; if (target._pendingMessage) { @@ -621,8 +621,8 @@ function setupChannel(target, channel, serializationMode) { target._pendingMessage.callback); } - for (var i = 0; i < queue.length; i++) { - var args = queue[i]; + for (let i = 0; i < queue.length; i++) { + const args = queue[i]; target._send(args.message, args.handle, args.options, args.callback); } @@ -854,7 +854,7 @@ function setupChannel(target, channel, serializationMode) { if (this._pendingMessage) closePendingHandle(this); - var fired = false; + let fired = false; function finish() { if (fired) return; fired = true; @@ -903,8 +903,8 @@ function isInternal(message) { function nop() { } function getValidStdio(stdio, sync) { - var ipc; - var ipcFd; + let ipc; + let ipcFd; // Replace shortcut with an array if (typeof stdio === 'string') { @@ -923,7 +923,7 @@ function getValidStdio(stdio, sync) { // (i.e. PipeWraps or fds) stdio = stdio.reduce((acc, stdio, i) => { function cleanup() { - for (var i = 0; i < acc.length; i++) { + for (let i = 0; i < acc.length; i++) { if ((acc[i].type === 'pipe' || acc[i].type === 'ipc') && acc[i].handle) acc[i].handle.close(); } @@ -937,7 +937,7 @@ function getValidStdio(stdio, sync) { if (stdio === 'ignore') { acc.push({ type: 'ignore' }); } else if (stdio === 'pipe' || (typeof stdio === 'number' && stdio < 0)) { - var a = { + const a = { type: 'pipe', readable: i === 0, writable: i !== 0 @@ -977,7 +977,7 @@ function getValidStdio(stdio, sync) { }); } else if (getHandleWrapType(stdio) || getHandleWrapType(stdio.handle) || getHandleWrapType(stdio._handle)) { - var handle = getHandleWrapType(stdio) ? + const handle = getHandleWrapType(stdio) ? stdio : getHandleWrapType(stdio.handle) ? stdio.handle : stdio._handle; @@ -1007,9 +1007,9 @@ function getValidStdio(stdio, sync) { function getSocketList(type, worker, key) { const sockets = worker.channel.sockets[type]; - var socketList = sockets[key]; + let socketList = sockets[key]; if (!socketList) { - var Construct = type === 'send' ? SocketListSend : SocketListReceive; + const Construct = type === 'send' ? SocketListSend : SocketListReceive; socketList = sockets[key] = new Construct(worker, key); } return socketList; @@ -1028,7 +1028,7 @@ function spawnSync(options) { const result = spawn_sync.spawn(options); if (result.output && options.encoding && options.encoding !== 'buffer') { - for (var i = 0; i < result.output.length; i++) { + for (let i = 0; i < result.output.length; i++) { if (!result.output[i]) continue; result.output[i] = result.output[i].toString(options.encoding); -- cgit v1.2.3