Skip to content
Permalink
Browse files

child_process: replace var with const/let in internal/child_process.js

PR-URL: #30414
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
  • Loading branch information
lcamargof authored and MylesBorins committed Nov 12, 2019
1 parent 46f698f commit 6974f26e26513ba0e9af95391e2bc6b501baafb1
Showing with 18 additions and 18 deletions.
  1. +18 −18 lib/internal/child_process.js
@@ -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
@@ -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
});
@@ -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)
@@ -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
@@ -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;
@@ -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) {
@@ -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);
}

@@ -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;
@@ -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') {
@@ -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();
}
@@ -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
@@ -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;

@@ -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;
@@ -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);

0 comments on commit 6974f26

Please sign in to comment.
You can’t perform that action at this time.