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: replaced var to let in lib/internal/child_process.js #30414

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
36 changes: 18 additions & 18 deletions lib/internal/child_process.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
});
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand All @@ -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);
}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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') {
Expand All @@ -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();
}
Expand All @@ -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
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand Down