Skip to content

Commit

Permalink
child_process: replace var with const/let in internal/child_process.js
Browse files Browse the repository at this point in the history
PR-URL: #30414
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Gireesh Punathil <[email protected]>
  • Loading branch information
lcamargof authored and MylesBorins committed Dec 17, 2019
1 parent 46f698f commit 6974f26
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions lib/internal/child_process.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,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
Expand Down Expand Up @@ -173,7 +173,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
});
Expand Down Expand Up @@ -260,7 +260,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)
Expand Down Expand Up @@ -292,7 +292,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
Expand Down Expand Up @@ -463,7 +463,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;
Expand Down Expand Up @@ -608,7 +608,7 @@ function setupChannel(target, channel) {
}

assert(Array.isArray(target._handleQueue));
var queue = target._handleQueue;
const queue = target._handleQueue;
target._handleQueue = null;

if (target._pendingMessage) {
Expand All @@ -618,8 +618,8 @@ function setupChannel(target, channel) {
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);
}

Expand Down Expand Up @@ -852,7 +852,7 @@ function setupChannel(target, channel) {
if (this._pendingMessage)
closePendingHandle(this);

var fired = false;
let fired = false;
function finish() {
if (fired) return;
fired = true;
Expand Down Expand Up @@ -901,8 +901,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') {
Expand All @@ -921,7 +921,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();
}
Expand All @@ -935,7 +935,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
Expand Down Expand Up @@ -975,7 +975,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;

Expand Down Expand Up @@ -1005,9 +1005,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;
Expand All @@ -1027,7 +1027,7 @@ function spawnSync(opts) {
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);
Expand Down

0 comments on commit 6974f26

Please sign in to comment.