@@ -38,8 +38,9 @@ exports.rootDir = exports.isWindows ? 'c:\\' : '/';
3838exports . buildType = process . config . target_defaults . default_configuration ;
3939
4040function rimrafSync ( p ) {
41+ let st ;
4142 try {
42- var st = fs . lstatSync ( p ) ;
43+ st = fs . lstatSync ( p ) ;
4344 } catch ( e ) {
4445 if ( e . code === 'ENOENT' )
4546 return ;
@@ -93,9 +94,9 @@ if (process.env.TEST_THREAD_ID) {
9394}
9495exports . tmpDir = path . join ( testRoot , exports . tmpDirName ) ;
9596
96- var opensslCli = null ;
97- var inFreeBSDJail = null ;
98- var localhostIPv4 = null ;
97+ let opensslCli = null ;
98+ let inFreeBSDJail = null ;
99+ let localhostIPv4 = null ;
99100
100101exports . localIPv6Hosts = [ 'localhost' ] ;
101102if ( exports . isLinux ) {
@@ -165,8 +166,8 @@ Object.defineProperty(exports, 'opensslCli', {get: function() {
165166
166167 if ( exports . isWindows ) opensslCli += '.exe' ;
167168
168- var openssl_cmd = child_process . spawnSync ( opensslCli , [ 'version' ] ) ;
169- if ( openssl_cmd . status !== 0 || openssl_cmd . error !== undefined ) {
169+ const opensslCmd = child_process . spawnSync ( opensslCli , [ 'version' ] ) ;
170+ if ( opensslCmd . status !== 0 || opensslCmd . error !== undefined ) {
170171 // openssl command cannot be executed
171172 opensslCli = false ;
172173 }
@@ -194,7 +195,7 @@ if (exports.isWindows) {
194195 exports . PIPE = exports . tmpDir + '/test.sock' ;
195196}
196197
197- var ifaces = os . networkInterfaces ( ) ;
198+ const ifaces = os . networkInterfaces ( ) ;
198199exports . hasIPv6 = Object . keys ( ifaces ) . some ( function ( name ) {
199200 return / l o / . test ( name ) && ifaces [ name ] . some ( function ( info ) {
200201 return info . family === 'IPv6' ;
@@ -204,7 +205,7 @@ exports.hasIPv6 = Object.keys(ifaces).some(function(name) {
204205
205206exports . ddCommand = function ( filename , kilobytes ) {
206207 if ( exports . isWindows ) {
207- var p = path . resolve ( exports . fixturesDir , 'create-file.js' ) ;
208+ const p = path . resolve ( exports . fixturesDir , 'create-file.js' ) ;
208209 return '"' + process . argv [ 0 ] + '" "' + p + '" "' +
209210 filename + '" ' + ( kilobytes * 1024 ) ;
210211 } else {
@@ -214,7 +215,7 @@ exports.ddCommand = function(filename, kilobytes) {
214215
215216
216217exports . spawnCat = function ( options ) {
217- var spawn = require ( 'child_process' ) . spawn ;
218+ const spawn = require ( 'child_process' ) . spawn ;
218219
219220 if ( exports . isWindows ) {
220221 return spawn ( 'more' , [ ] , options ) ;
@@ -225,7 +226,7 @@ exports.spawnCat = function(options) {
225226
226227
227228exports . spawnSyncCat = function ( options ) {
228- var spawnSync = require ( 'child_process' ) . spawnSync ;
229+ const spawnSync = require ( 'child_process' ) . spawnSync ;
229230
230231 if ( exports . isWindows ) {
231232 return spawnSync ( 'more' , [ ] , options ) ;
@@ -236,7 +237,7 @@ exports.spawnSyncCat = function(options) {
236237
237238
238239exports . spawnPwd = function ( options ) {
239- var spawn = require ( 'child_process' ) . spawn ;
240+ const spawn = require ( 'child_process' ) . spawn ;
240241
241242 if ( exports . isWindows ) {
242243 return spawn ( 'cmd.exe' , [ '/c' , 'cd' ] , options ) ;
@@ -277,7 +278,7 @@ exports.platformTimeout = function(ms) {
277278 return ms ; // ARMv8+
278279} ;
279280
280- var knownGlobals = [
281+ let knownGlobals = [
281282 Buffer ,
282283 clearImmediate ,
283284 clearInterval ,
@@ -351,9 +352,9 @@ function allowGlobals(...whitelist) {
351352exports . allowGlobals = allowGlobals ;
352353
353354function leakedGlobals ( ) {
354- var leaked = [ ] ;
355+ const leaked = [ ] ;
355356
356- for ( var val in global )
357+ for ( const val in global )
357358 if ( ! knownGlobals . includes ( global [ val ] ) )
358359 leaked . push ( val ) ;
359360
@@ -366,21 +367,21 @@ exports.globalCheck = true;
366367
367368process . on ( 'exit' , function ( ) {
368369 if ( ! exports . globalCheck ) return ;
369- var leaked = leakedGlobals ( ) ;
370+ const leaked = leakedGlobals ( ) ;
370371 if ( leaked . length > 0 ) {
371372 console . error ( 'Unknown globals: %s' , leaked ) ;
372373 fail ( 'Unknown global found' ) ;
373374 }
374375} ) ;
375376
376377
377- var mustCallChecks = [ ] ;
378+ const mustCallChecks = [ ] ;
378379
379380
380381function runCallChecks ( exitCode ) {
381382 if ( exitCode !== 0 ) return ;
382383
383- var failed = mustCallChecks . filter ( function ( context ) {
384+ const failed = mustCallChecks . filter ( function ( context ) {
384385 return context . actual !== context . expected ;
385386 } ) ;
386387
@@ -399,7 +400,7 @@ function runCallChecks(exitCode) {
399400exports . mustCall = function ( fn , expected ) {
400401 if ( typeof expected !== 'number' ) expected = 1 ;
401402
402- var context = {
403+ const context = {
403404 expected : expected ,
404405 actual : 0 ,
405406 stack : ( new Error ( ) ) . stack ,
@@ -418,9 +419,9 @@ exports.mustCall = function(fn, expected) {
418419} ;
419420
420421exports . hasMultiLocalhost = function hasMultiLocalhost ( ) {
421- var TCP = process . binding ( 'tcp_wrap' ) . TCP ;
422- var t = new TCP ( ) ;
423- var ret = t . bind ( '127.0.0.2' , exports . PORT ) ;
422+ const TCP = process . binding ( 'tcp_wrap' ) . TCP ;
423+ const t = new TCP ( ) ;
424+ const ret = t . bind ( '127.0.0.2' , exports . PORT ) ;
424425 t . close ( ) ;
425426 return ret === 0 ;
426427} ;
@@ -466,7 +467,7 @@ ArrayStream.prototype.write = function() {};
466467exports . nodeProcessAborted = function nodeProcessAborted ( exitCode , signal ) {
467468 // Depending on the compiler used, node will exit with either
468469 // exit code 132 (SIGILL), 133 (SIGTRAP) or 134 (SIGABRT).
469- var expectedExitCodes = [ 132 , 133 , 134 ] ;
470+ let expectedExitCodes = [ 132 , 133 , 134 ] ;
470471
471472 // On platforms using KSH as the default shell (like SmartOS),
472473 // when a process aborts, KSH exits with an exit code that is
@@ -495,8 +496,8 @@ exports.nodeProcessAborted = function nodeProcessAborted(exitCode, signal) {
495496} ;
496497
497498exports . busyLoop = function busyLoop ( time ) {
498- var startTime = Timer . now ( ) ;
499- var stopTime = startTime + time ;
499+ const startTime = Timer . now ( ) ;
500+ const stopTime = startTime + time ;
500501 while ( Timer . now ( ) < stopTime ) { }
501502} ;
502503
0 commit comments