@@ -41,8 +41,9 @@ exports.rootDir = exports.isWindows ? 'c:\\' : '/';
4141exports . buildType = process . config . target_defaults . default_configuration ;
4242
4343function rimrafSync ( p ) {
44+ let st ;
4445 try {
45- var st = fs . lstatSync ( p ) ;
46+ st = fs . lstatSync ( p ) ;
4647 } catch ( e ) {
4748 if ( e . code === 'ENOENT' )
4849 return ;
@@ -96,9 +97,9 @@ if (process.env.TEST_THREAD_ID) {
9697}
9798exports . tmpDir = path . join ( testRoot , exports . tmpDirName ) ;
9899
99- var opensslCli = null ;
100- var inFreeBSDJail = null ;
101- var localhostIPv4 = null ;
100+ let opensslCli = null ;
101+ let inFreeBSDJail = null ;
102+ let localhostIPv4 = null ;
102103
103104exports . localIPv6Hosts = [ 'localhost' ] ;
104105if ( exports . isLinux ) {
@@ -168,8 +169,8 @@ Object.defineProperty(exports, 'opensslCli', {get: function() {
168169
169170 if ( exports . isWindows ) opensslCli += '.exe' ;
170171
171- var openssl_cmd = child_process . spawnSync ( opensslCli , [ 'version' ] ) ;
172- if ( openssl_cmd . status !== 0 || openssl_cmd . error !== undefined ) {
172+ const opensslCmd = child_process . spawnSync ( opensslCli , [ 'version' ] ) ;
173+ if ( opensslCmd . status !== 0 || opensslCmd . error !== undefined ) {
173174 // openssl command cannot be executed
174175 opensslCli = false ;
175176 }
@@ -197,7 +198,7 @@ if (exports.isWindows) {
197198 exports . PIPE = exports . tmpDir + '/test.sock' ;
198199}
199200
200- var ifaces = os . networkInterfaces ( ) ;
201+ const ifaces = os . networkInterfaces ( ) ;
201202exports . hasIPv6 = Object . keys ( ifaces ) . some ( function ( name ) {
202203 return / l o / . test ( name ) && ifaces [ name ] . some ( function ( info ) {
203204 return info . family === 'IPv6' ;
@@ -229,7 +230,7 @@ exports.childShouldThrowAndAbort = function() {
229230
230231exports . ddCommand = function ( filename , kilobytes ) {
231232 if ( exports . isWindows ) {
232- var p = path . resolve ( exports . fixturesDir , 'create-file.js' ) ;
233+ const p = path . resolve ( exports . fixturesDir , 'create-file.js' ) ;
233234 return '"' + process . argv [ 0 ] + '" "' + p + '" "' +
234235 filename + '" ' + ( kilobytes * 1024 ) ;
235236 } else {
@@ -239,7 +240,7 @@ exports.ddCommand = function(filename, kilobytes) {
239240
240241
241242exports . spawnCat = function ( options ) {
242- var spawn = require ( 'child_process' ) . spawn ;
243+ const spawn = require ( 'child_process' ) . spawn ;
243244
244245 if ( exports . isWindows ) {
245246 return spawn ( 'more' , [ ] , options ) ;
@@ -250,7 +251,7 @@ exports.spawnCat = function(options) {
250251
251252
252253exports . spawnSyncCat = function ( options ) {
253- var spawnSync = require ( 'child_process' ) . spawnSync ;
254+ const spawnSync = require ( 'child_process' ) . spawnSync ;
254255
255256 if ( exports . isWindows ) {
256257 return spawnSync ( 'more' , [ ] , options ) ;
@@ -261,7 +262,7 @@ exports.spawnSyncCat = function(options) {
261262
262263
263264exports . spawnPwd = function ( options ) {
264- var spawn = require ( 'child_process' ) . spawn ;
265+ const spawn = require ( 'child_process' ) . spawn ;
265266
266267 if ( exports . isWindows ) {
267268 return spawn ( 'cmd.exe' , [ '/d' , '/c' , 'cd' ] , options ) ;
@@ -302,7 +303,7 @@ exports.platformTimeout = function(ms) {
302303 return ms ; // ARMv8+
303304} ;
304305
305- var knownGlobals = [
306+ let knownGlobals = [
306307 Buffer ,
307308 clearImmediate ,
308309 clearInterval ,
@@ -376,9 +377,9 @@ function allowGlobals(...whitelist) {
376377exports . allowGlobals = allowGlobals ;
377378
378379function leakedGlobals ( ) {
379- var leaked = [ ] ;
380+ const leaked = [ ] ;
380381
381- for ( var val in global )
382+ for ( const val in global )
382383 if ( ! knownGlobals . includes ( global [ val ] ) )
383384 leaked . push ( val ) ;
384385
@@ -391,21 +392,21 @@ exports.globalCheck = true;
391392
392393process . on ( 'exit' , function ( ) {
393394 if ( ! exports . globalCheck ) return ;
394- var leaked = leakedGlobals ( ) ;
395+ const leaked = leakedGlobals ( ) ;
395396 if ( leaked . length > 0 ) {
396397 console . error ( 'Unknown globals: %s' , leaked ) ;
397398 fail ( 'Unknown global found' ) ;
398399 }
399400} ) ;
400401
401402
402- var mustCallChecks = [ ] ;
403+ const mustCallChecks = [ ] ;
403404
404405
405406function runCallChecks ( exitCode ) {
406407 if ( exitCode !== 0 ) return ;
407408
408- var failed = mustCallChecks . filter ( function ( context ) {
409+ const failed = mustCallChecks . filter ( function ( context ) {
409410 return context . actual !== context . expected ;
410411 } ) ;
411412
@@ -424,7 +425,7 @@ function runCallChecks(exitCode) {
424425exports . mustCall = function ( fn , expected ) {
425426 if ( typeof expected !== 'number' ) expected = 1 ;
426427
427- var context = {
428+ const context = {
428429 expected : expected ,
429430 actual : 0 ,
430431 stack : ( new Error ( ) ) . stack ,
@@ -443,9 +444,9 @@ exports.mustCall = function(fn, expected) {
443444} ;
444445
445446exports . hasMultiLocalhost = function hasMultiLocalhost ( ) {
446- var TCP = process . binding ( 'tcp_wrap' ) . TCP ;
447- var t = new TCP ( ) ;
448- var ret = t . bind ( '127.0.0.2' , exports . PORT ) ;
447+ const TCP = process . binding ( 'tcp_wrap' ) . TCP ;
448+ const t = new TCP ( ) ;
449+ const ret = t . bind ( '127.0.0.2' , exports . PORT ) ;
449450 t . close ( ) ;
450451 return ret === 0 ;
451452} ;
@@ -491,7 +492,7 @@ ArrayStream.prototype.write = function() {};
491492exports . nodeProcessAborted = function nodeProcessAborted ( exitCode , signal ) {
492493 // Depending on the compiler used, node will exit with either
493494 // exit code 132 (SIGILL), 133 (SIGTRAP) or 134 (SIGABRT).
494- var expectedExitCodes = [ 132 , 133 , 134 ] ;
495+ let expectedExitCodes = [ 132 , 133 , 134 ] ;
495496
496497 // On platforms using KSH as the default shell (like SmartOS),
497498 // when a process aborts, KSH exits with an exit code that is
@@ -520,8 +521,8 @@ exports.nodeProcessAborted = function nodeProcessAborted(exitCode, signal) {
520521} ;
521522
522523exports . busyLoop = function busyLoop ( time ) {
523- var startTime = Timer . now ( ) ;
524- var stopTime = startTime + time ;
524+ const startTime = Timer . now ( ) ;
525+ const stopTime = startTime + time ;
525526 while ( Timer . now ( ) < stopTime ) { }
526527} ;
527528
0 commit comments