Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4b13bca

Browse filesBrowse files
lcamargofaddaleax
authored andcommitted
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>
1 parent d8da9da commit 4b13bca
Copy full SHA for 4b13bca

File tree

Expand file treeCollapse file tree

1 file changed

+18
-18
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+18
-18
lines changed
Open diff view settings
Collapse file

‎lib/internal/child_process.js‎

Copy file name to clipboardExpand all lines: lib/internal/child_process.js
+18-18Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ const handleConversion = {
103103
// The worker should keep track of the socket
104104
message.key = socket.server._connectionKey;
105105

106-
var firstTime = !this.channel.sockets.send[message.key];
107-
var socketList = getSocketList('send', this, message.key);
106+
const firstTime = !this.channel.sockets.send[message.key];
107+
const socketList = getSocketList('send', this, message.key);
108108

109109
// The server should no longer expose a .connection property
110110
// and when asked to close it should query the socket status from
@@ -171,7 +171,7 @@ const handleConversion = {
171171
if (message.key) {
172172

173173
// Add socket to connections list
174-
var socketList = getSocketList('got', this, message.key);
174+
const socketList = getSocketList('got', this, message.key);
175175
socketList.add({
176176
socket: socket
177177
});
@@ -258,7 +258,7 @@ function ChildProcess() {
258258
this._handle = null;
259259

260260
if (exitCode < 0) {
261-
var syscall = this.spawnfile ? 'spawn ' + this.spawnfile : 'spawn';
261+
const syscall = this.spawnfile ? 'spawn ' + this.spawnfile : 'spawn';
262262
const err = errnoException(exitCode, syscall);
263263

264264
if (this.spawnfile)
@@ -290,7 +290,7 @@ function flushStdio(subprocess) {
290290

291291
if (stdio == null) return;
292292

293-
for (var i = 0; i < stdio.length; i++) {
293+
for (let i = 0; i < stdio.length; i++) {
294294
const stream = stdio[i];
295295
// TODO(addaleax): This doesn't necessarily account for all the ways in
296296
// which data can be read from a stream, e.g. being consumed on the
@@ -471,7 +471,7 @@ ChildProcess.prototype.kill = function(sig) {
471471
convertToValidSignal(sig === undefined ? 'SIGTERM' : sig);
472472

473473
if (this._handle) {
474-
var err = this._handle.kill(signal);
474+
const err = this._handle.kill(signal);
475475
if (err === 0) {
476476
/* Success. */
477477
this.killed = true;
@@ -611,7 +611,7 @@ function setupChannel(target, channel, serializationMode) {
611611
}
612612

613613
assert(Array.isArray(target._handleQueue));
614-
var queue = target._handleQueue;
614+
const queue = target._handleQueue;
615615
target._handleQueue = null;
616616

617617
if (target._pendingMessage) {
@@ -621,8 +621,8 @@ function setupChannel(target, channel, serializationMode) {
621621
target._pendingMessage.callback);
622622
}
623623

624-
for (var i = 0; i < queue.length; i++) {
625-
var args = queue[i];
624+
for (let i = 0; i < queue.length; i++) {
625+
const args = queue[i];
626626
target._send(args.message, args.handle, args.options, args.callback);
627627
}
628628

@@ -854,7 +854,7 @@ function setupChannel(target, channel, serializationMode) {
854854
if (this._pendingMessage)
855855
closePendingHandle(this);
856856

857-
var fired = false;
857+
let fired = false;
858858
function finish() {
859859
if (fired) return;
860860
fired = true;
@@ -903,8 +903,8 @@ function isInternal(message) {
903903
function nop() { }
904904

905905
function getValidStdio(stdio, sync) {
906-
var ipc;
907-
var ipcFd;
906+
let ipc;
907+
let ipcFd;
908908

909909
// Replace shortcut with an array
910910
if (typeof stdio === 'string') {
@@ -923,7 +923,7 @@ function getValidStdio(stdio, sync) {
923923
// (i.e. PipeWraps or fds)
924924
stdio = stdio.reduce((acc, stdio, i) => {
925925
function cleanup() {
926-
for (var i = 0; i < acc.length; i++) {
926+
for (let i = 0; i < acc.length; i++) {
927927
if ((acc[i].type === 'pipe' || acc[i].type === 'ipc') && acc[i].handle)
928928
acc[i].handle.close();
929929
}
@@ -937,7 +937,7 @@ function getValidStdio(stdio, sync) {
937937
if (stdio === 'ignore') {
938938
acc.push({ type: 'ignore' });
939939
} else if (stdio === 'pipe' || (typeof stdio === 'number' && stdio < 0)) {
940-
var a = {
940+
const a = {
941941
type: 'pipe',
942942
readable: i === 0,
943943
writable: i !== 0
@@ -977,7 +977,7 @@ function getValidStdio(stdio, sync) {
977977
});
978978
} else if (getHandleWrapType(stdio) || getHandleWrapType(stdio.handle) ||
979979
getHandleWrapType(stdio._handle)) {
980-
var handle = getHandleWrapType(stdio) ?
980+
const handle = getHandleWrapType(stdio) ?
981981
stdio :
982982
getHandleWrapType(stdio.handle) ? stdio.handle : stdio._handle;
983983

@@ -1007,9 +1007,9 @@ function getValidStdio(stdio, sync) {
10071007

10081008
function getSocketList(type, worker, key) {
10091009
const sockets = worker.channel.sockets[type];
1010-
var socketList = sockets[key];
1010+
let socketList = sockets[key];
10111011
if (!socketList) {
1012-
var Construct = type === 'send' ? SocketListSend : SocketListReceive;
1012+
const Construct = type === 'send' ? SocketListSend : SocketListReceive;
10131013
socketList = sockets[key] = new Construct(worker, key);
10141014
}
10151015
return socketList;
@@ -1028,7 +1028,7 @@ function spawnSync(options) {
10281028
const result = spawn_sync.spawn(options);
10291029

10301030
if (result.output && options.encoding && options.encoding !== 'buffer') {
1031-
for (var i = 0; i < result.output.length; i++) {
1031+
for (let i = 0; i < result.output.length; i++) {
10321032
if (!result.output[i])
10331033
continue;
10341034
result.output[i] = result.output[i].toString(options.encoding);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.