@@ -158,7 +158,7 @@ Module.builtinModules = builtinModules;
158
158
Module . _cache = Object . create ( null ) ;
159
159
Module . _pathCache = Object . create ( null ) ;
160
160
Module . _extensions = Object . create ( null ) ;
161
- var modulePaths = [ ] ;
161
+ let modulePaths = [ ] ;
162
162
Module . globalPaths = [ ] ;
163
163
164
164
let patched = false ;
@@ -347,7 +347,7 @@ function toRealPath(requestPath) {
347
347
348
348
// Given a path, check if the file exists with any of the set extensions
349
349
function tryExtensions ( p , exts , isMain ) {
350
- for ( var i = 0 ; i < exts . length ; i ++ ) {
350
+ for ( let i = 0 ; i < exts . length ; i ++ ) {
351
351
const filename = tryFile ( p + exts [ i ] , isMain ) ;
352
352
353
353
if ( filename ) {
@@ -625,22 +625,22 @@ Module._findPath = function(request, paths, isMain) {
625
625
if ( entry )
626
626
return entry ;
627
627
628
- var exts ;
629
- var trailingSlash = request . length > 0 &&
628
+ let exts ;
629
+ let trailingSlash = request . length > 0 &&
630
630
request . charCodeAt ( request . length - 1 ) === CHAR_FORWARD_SLASH ;
631
631
if ( ! trailingSlash ) {
632
632
trailingSlash = / (?: ^ | \/ ) \. ? \. $ / . test ( request ) ;
633
633
}
634
634
635
635
// For each path
636
- for ( var i = 0 ; i < paths . length ; i ++ ) {
636
+ for ( let i = 0 ; i < paths . length ; i ++ ) {
637
637
// Don't search further if path doesn't exist
638
638
const curPath = paths [ i ] ;
639
639
if ( curPath && stat ( curPath ) < 1 ) continue ;
640
- var basePath = resolveExports ( curPath , request , absoluteRequest ) ;
641
- var filename ;
640
+ const basePath = resolveExports ( curPath , request , absoluteRequest ) ;
641
+ let filename ;
642
642
643
- var rc = stat ( basePath ) ;
643
+ const rc = stat ( basePath ) ;
644
644
if ( ! trailingSlash ) {
645
645
if ( rc === 0 ) { // File.
646
646
if ( ! isMain ) {
@@ -714,9 +714,7 @@ if (isWindows) {
714
714
return [ from + 'node_modules' ] ;
715
715
716
716
const paths = [ ] ;
717
- var p = 0 ;
718
- var last = from . length ;
719
- for ( var i = from . length - 1 ; i >= 0 ; -- i ) {
717
+ for ( let i = from . length - 1 , p = 0 , last = from . length ; i >= 0 ; -- i ) {
720
718
const code = from . charCodeAt ( i ) ;
721
719
// The path segment separator check ('\' and '/') was used to get
722
720
// node_modules path for every path segment.
@@ -755,9 +753,7 @@ if (isWindows) {
755
753
// to be absolute. Doing a fully-edge-case-correct path.split
756
754
// that works on both Windows and Posix is non-trivial.
757
755
const paths = [ ] ;
758
- var p = 0 ;
759
- var last = from . length ;
760
- for ( var i = from . length - 1 ; i >= 0 ; -- i ) {
756
+ for ( let i = from . length - 1 , p = 0 , last = from . length ; i >= 0 ; -- i ) {
761
757
const code = from . charCodeAt ( i ) ;
762
758
if ( code === CHAR_FORWARD_SLASH ) {
763
759
if ( p !== nmLen )
@@ -902,7 +898,7 @@ Module._resolveFilename = function(request, parent, isMain, options) {
902
898
return request ;
903
899
}
904
900
905
- var paths ;
901
+ let paths ;
906
902
907
903
if ( typeof options === 'object' && options !== null ) {
908
904
if ( Array . isArray ( options . paths ) ) {
@@ -918,12 +914,12 @@ Module._resolveFilename = function(request, parent, isMain, options) {
918
914
919
915
paths = [ ] ;
920
916
921
- for ( var i = 0 ; i < options . paths . length ; i ++ ) {
917
+ for ( let i = 0 ; i < options . paths . length ; i ++ ) {
922
918
const path = options . paths [ i ] ;
923
919
fakeParent . paths = Module . _nodeModulePaths ( path ) ;
924
920
const lookupPaths = Module . _resolveLookupPaths ( request , fakeParent ) ;
925
921
926
- for ( var j = 0 ; j < lookupPaths . length ; j ++ ) {
922
+ for ( let j = 0 ; j < lookupPaths . length ; j ++ ) {
927
923
if ( ! paths . includes ( lookupPaths [ j ] ) )
928
924
paths . push ( lookupPaths [ j ] ) ;
929
925
}
@@ -942,7 +938,7 @@ Module._resolveFilename = function(request, parent, isMain, options) {
942
938
const filename = Module . _findPath ( request , paths , isMain ) ;
943
939
if ( ! filename ) {
944
940
const requireStack = [ ] ;
945
- for ( var cursor = parent ;
941
+ for ( let cursor = parent ;
946
942
cursor ;
947
943
cursor = cursor . parent ) {
948
944
requireStack . push ( cursor . filename || cursor . id ) ;
@@ -952,7 +948,7 @@ Module._resolveFilename = function(request, parent, isMain, options) {
952
948
message = message + '\nRequire stack:\n- ' + requireStack . join ( '\n- ' ) ;
953
949
}
954
950
// eslint-disable-next-line no-restricted-syntax
955
- var err = new Error ( message ) ;
951
+ const err = new Error ( message ) ;
956
952
err . code = 'MODULE_NOT_FOUND' ;
957
953
err . requireStack = requireStack ;
958
954
throw err ;
@@ -1023,7 +1019,7 @@ Module.prototype.require = function(id) {
1023
1019
1024
1020
// Resolved path to process.argv[1] will be lazily placed here
1025
1021
// (needed for setting breakpoint when called with --inspect-brk)
1026
- var resolvedArgv ;
1022
+ let resolvedArgv ;
1027
1023
let hasPausedEntry = false ;
1028
1024
1029
1025
function wrapSafe ( filename , content , cjsModuleInstance ) {
@@ -1091,7 +1087,7 @@ Module.prototype._compile = function(content, filename) {
1091
1087
maybeCacheSourceMap ( filename , content , this ) ;
1092
1088
const compiledWrapper = wrapSafe ( filename , content , this ) ;
1093
1089
1094
- var inspectorWrapper = null ;
1090
+ let inspectorWrapper = null ;
1095
1091
if ( getOptionValue ( '--inspect-brk' ) && process . _eval == null ) {
1096
1092
if ( ! resolvedArgv ) {
1097
1093
// We enter the repl if we're not given a filename argument.
@@ -1110,7 +1106,7 @@ Module.prototype._compile = function(content, filename) {
1110
1106
}
1111
1107
const dirname = path . dirname ( filename ) ;
1112
1108
const require = makeRequireFunction ( this , redirects ) ;
1113
- var result ;
1109
+ let result ;
1114
1110
const exports = this . exports ;
1115
1111
const thisValue = exports ;
1116
1112
const module = this ;
@@ -1249,26 +1245,16 @@ function createRequire(filename) {
1249
1245
Module . createRequire = createRequire ;
1250
1246
1251
1247
Module . _initPaths = function ( ) {
1252
- var homeDir ;
1253
- var nodePath ;
1254
- if ( isWindows ) {
1255
- homeDir = process . env . USERPROFILE ;
1256
- nodePath = process . env . NODE_PATH ;
1257
- } else {
1258
- homeDir = safeGetenv ( 'HOME' ) ;
1259
- nodePath = safeGetenv ( 'NODE_PATH' ) ;
1260
- }
1248
+ const homeDir = isWindows ? process . env . USERPROFILE : safeGetenv ( 'HOME' ) ;
1249
+ const nodePath = isWindows ? process . env . NODE_PATH : safeGetenv ( 'NODE_PATH' ) ;
1261
1250
1262
- // $PREFIX/lib/node, where $PREFIX is the root of the Node.js installation.
1263
- var prefixDir ;
1264
1251
// process.execPath is $PREFIX/bin/node except on Windows where it is
1265
- // $PREFIX\node.exe.
1266
- if ( isWindows ) {
1267
- prefixDir = path . resolve ( process . execPath , '..' ) ;
1268
- } else {
1269
- prefixDir = path . resolve ( process . execPath , '..' , '..' ) ;
1270
- }
1271
- var paths = [ path . resolve ( prefixDir , 'lib' , 'node' ) ] ;
1252
+ // $PREFIX\node.exe where $PREFIX is the root of the Node.js installation.
1253
+ const prefixDir = isWindows ?
1254
+ path . resolve ( process . execPath , '..' ) :
1255
+ path . resolve ( process . execPath , '..' , '..' ) ;
1256
+
1257
+ let paths = [ path . resolve ( prefixDir , 'lib' , 'node' ) ] ;
1272
1258
1273
1259
if ( homeDir ) {
1274
1260
paths . unshift ( path . resolve ( homeDir , '.node_libraries' ) ) ;
@@ -1302,7 +1288,7 @@ Module._preloadModules = function(requests) {
1302
1288
throw e ;
1303
1289
}
1304
1290
}
1305
- for ( var n = 0 ; n < requests . length ; n ++ )
1291
+ for ( let n = 0 ; n < requests . length ; n ++ )
1306
1292
parent . require ( requests [ n ] ) ;
1307
1293
} ;
1308
1294
0 commit comments