@@ -173,7 +173,7 @@ function stat(filename) {
173
173
filename = path . toNamespacedPath ( filename ) ;
174
174
if ( statCache !== null ) {
175
175
const result = statCache . get ( filename ) ;
176
- if ( result !== undefined ) return result ;
176
+ if ( result !== undefined ) { return result ; }
177
177
}
178
178
const result = internalModuleStat ( filename ) ;
179
179
if ( statCache !== null && result >= 0 ) {
@@ -197,8 +197,9 @@ ObjectDefineProperty(Module, '_stat', {
197
197
198
198
function updateChildren ( parent , child , scan ) {
199
199
const children = parent ?. children ;
200
- if ( children && ! ( scan && ArrayPrototypeIncludes ( children , child ) ) )
200
+ if ( children && ! ( scan && ArrayPrototypeIncludes ( children , child ) ) ) {
201
201
ArrayPrototypePush ( children , child ) ;
202
+ }
202
203
}
203
204
204
205
function reportModuleToWatchMode ( filename ) {
@@ -386,13 +387,16 @@ function readPackageScope(checkPath) {
386
387
if ( enabledPermission && ! permission . has ( 'fs.read' , checkPath + sep ) ) {
387
388
return false ;
388
389
}
389
- if ( StringPrototypeEndsWith ( checkPath , sep + 'node_modules' ) )
390
+ if ( StringPrototypeEndsWith ( checkPath , sep + 'node_modules' ) ) {
390
391
return false ;
392
+ }
391
393
const pjson = _readPackage ( checkPath + sep ) ;
392
- if ( pjson . exists ) return {
393
- data : pjson ,
394
- path : checkPath ,
395
- } ;
394
+ if ( pjson . exists ) {
395
+ return {
396
+ data : pjson ,
397
+ path : checkPath ,
398
+ } ;
399
+ }
396
400
} while ( separatorIndex > rootSeparatorIndex ) ;
397
401
return false ;
398
402
}
@@ -445,7 +449,7 @@ const realpathCache = new SafeMap();
445
449
// absolute realpath.
446
450
function tryFile ( requestPath , isMain ) {
447
451
const rc = _stat ( requestPath ) ;
448
- if ( rc !== 0 ) return ;
452
+ if ( rc !== 0 ) { return ; }
449
453
if ( getOptionValue ( '--preserve-symlinks' ) && ! isMain ) {
450
454
return path . resolve ( requestPath ) ;
451
455
}
@@ -479,15 +483,15 @@ function findLongestRegisteredExtension(filename) {
479
483
let startIndex = 0 ;
480
484
while ( ( index = StringPrototypeIndexOf ( name , '.' , startIndex ) ) !== - 1 ) {
481
485
startIndex = index + 1 ;
482
- if ( index === 0 ) continue ; // Skip dotfiles like .gitignore
486
+ if ( index === 0 ) { continue ; } // Skip dotfiles like .gitignore
483
487
currentExtension = StringPrototypeSlice ( name , index ) ;
484
- if ( Module . _extensions [ currentExtension ] ) return currentExtension ;
488
+ if ( Module . _extensions [ currentExtension ] ) { return currentExtension ; }
485
489
}
486
490
return '.js' ;
487
491
}
488
492
489
493
function trySelfParentPath ( parent ) {
490
- if ( ! parent ) return false ;
494
+ if ( ! parent ) { return false ; }
491
495
492
496
if ( parent . filename ) {
493
497
return parent . filename ;
@@ -501,7 +505,7 @@ function trySelfParentPath(parent) {
501
505
}
502
506
503
507
function trySelf ( parentPath , request ) {
504
- if ( ! parentPath ) return false ;
508
+ if ( ! parentPath ) { return false ; }
505
509
506
510
const { data : pkg , path : pkgPath } = readPackageScope ( parentPath ) ;
507
511
if ( ! pkg || pkg . exports == null || pkg . name === undefined ) {
@@ -523,8 +527,9 @@ function trySelf(parentPath, request) {
523
527
pathToFileURL ( pkgPath + '/package.json' ) , expansion , pkg ,
524
528
pathToFileURL ( parentPath ) , getCjsConditions ( ) ) , parentPath , pkgPath ) ;
525
529
} catch ( e ) {
526
- if ( e . code === 'ERR_MODULE_NOT_FOUND' )
530
+ if ( e . code === 'ERR_MODULE_NOT_FOUND' ) {
527
531
throw createEsmNotFoundErr ( request , pkgPath + '/package.json' ) ;
532
+ }
528
533
throw e ;
529
534
}
530
535
}
@@ -537,8 +542,7 @@ function resolveExports(nmPath, request) {
537
542
// The implementation's behavior is meant to mirror resolution in ESM.
538
543
const { 1 : name , 2 : expansion = '' } =
539
544
RegExpPrototypeExec ( EXPORTS_PATTERN , request ) || kEmptyObject ;
540
- if ( ! name )
541
- return ;
545
+ if ( ! name ) { return ; }
542
546
const pkgPath = path . resolve ( nmPath , name ) ;
543
547
const pkg = _readPackage ( pkgPath ) ;
544
548
if ( pkg . exists && pkg . exports != null ) {
@@ -548,8 +552,9 @@ function resolveExports(nmPath, request) {
548
552
pathToFileURL ( pkgPath + '/package.json' ) , '.' + expansion , pkg , null ,
549
553
getCjsConditions ( ) ) , null , pkgPath ) ;
550
554
} catch ( e ) {
551
- if ( e . code === 'ERR_MODULE_NOT_FOUND' )
555
+ if ( e . code === 'ERR_MODULE_NOT_FOUND' ) {
552
556
throw createEsmNotFoundErr ( request , pkgPath + '/package.json' ) ;
557
+ }
553
558
throw e ;
554
559
}
555
560
}
@@ -571,8 +576,9 @@ Module._findPath = function(request, paths, isMain) {
571
576
572
577
const cacheKey = request + '\x00' + ArrayPrototypeJoin ( paths , '\x00' ) ;
573
578
const entry = Module . _pathCache [ cacheKey ] ;
574
- if ( entry )
579
+ if ( entry ) {
575
580
return entry ;
581
+ }
576
582
577
583
let exts ;
578
584
const trailingSlash = request . length > 0 &&
@@ -619,8 +625,9 @@ Module._findPath = function(request, paths, isMain) {
619
625
620
626
if ( ! absoluteRequest ) {
621
627
const exportsResolved = resolveExports ( curPath , request ) ;
622
- if ( exportsResolved )
628
+ if ( exportsResolved ) {
623
629
return exportsResolved ;
630
+ }
624
631
}
625
632
626
633
const basePath = path . resolve ( curPath , request ) ;
@@ -652,16 +659,18 @@ Module._findPath = function(request, paths, isMain) {
652
659
653
660
if ( ! filename ) {
654
661
// Try it with each of the extensions
655
- if ( exts === undefined )
662
+ if ( exts === undefined ) {
656
663
exts = ObjectKeys ( Module . _extensions ) ;
664
+ }
657
665
filename = tryExtensions ( basePath , exts , isMain ) ;
658
666
}
659
667
}
660
668
661
669
if ( ! filename && rc === 1 ) { // Directory.
662
670
// try it with each of the extensions at "index"
663
- if ( exts === undefined )
671
+ if ( exts === undefined ) {
664
672
exts = ObjectKeys ( Module . _extensions ) ;
673
+ }
665
674
filename = tryPackage ( basePath , exts , isMain , request ) ;
666
675
}
667
676
@@ -697,8 +706,9 @@ if (isWindows) {
697
706
// path.resolve will make sure from.length >=3 in Windows.
698
707
if ( StringPrototypeCharCodeAt ( from , from . length - 1 ) ===
699
708
CHAR_BACKWARD_SLASH &&
700
- StringPrototypeCharCodeAt ( from , from . length - 2 ) === CHAR_COLON )
709
+ StringPrototypeCharCodeAt ( from , from . length - 2 ) === CHAR_COLON ) {
701
710
return [ from + 'node_modules' ] ;
711
+ }
702
712
703
713
const paths = [ ] ;
704
714
for ( let i = from . length - 1 , p = 0 , last = from . length ; i >= 0 ; -- i ) {
@@ -711,11 +721,12 @@ if (isWindows) {
711
721
if ( code === CHAR_BACKWARD_SLASH ||
712
722
code === CHAR_FORWARD_SLASH ||
713
723
code === CHAR_COLON ) {
714
- if ( p !== nmLen )
724
+ if ( p !== nmLen ) {
715
725
ArrayPrototypePush (
716
726
paths ,
717
727
StringPrototypeSlice ( from , 0 , last ) + '\\node_modules' ,
718
728
) ;
729
+ }
719
730
last = i ;
720
731
p = 0 ;
721
732
} else if ( p !== - 1 ) {
@@ -736,8 +747,9 @@ if (isWindows) {
736
747
from = path . resolve ( from ) ;
737
748
// Return early not only to avoid unnecessary work, but to *avoid* returning
738
749
// an array of two items for a root: [ '//node_modules', '/node_modules' ]
739
- if ( from === '/' )
750
+ if ( from === '/' ) {
740
751
return [ '/node_modules' ] ;
752
+ }
741
753
742
754
// note: this approach *only* works when the path is guaranteed
743
755
// to be absolute. Doing a fully-edge-case-correct path.split
@@ -746,11 +758,12 @@ if (isWindows) {
746
758
for ( let i = from . length - 1 , p = 0 , last = from . length ; i >= 0 ; -- i ) {
747
759
const code = StringPrototypeCharCodeAt ( from , i ) ;
748
760
if ( code === CHAR_FORWARD_SLASH ) {
749
- if ( p !== nmLen )
761
+ if ( p !== nmLen ) {
750
762
ArrayPrototypePush (
751
763
paths ,
752
764
StringPrototypeSlice ( from , 0 , last ) + '/node_modules' ,
753
765
) ;
766
+ }
754
767
last = i ;
755
768
p = 0 ;
756
769
} else if ( p !== - 1 ) {
@@ -827,14 +840,15 @@ const CircularRequirePrototypeWarningProxy = new Proxy({}, {
827
840
// Allow __esModule access in any case because it is used in the output
828
841
// of transpiled code to determine whether something comes from an
829
842
// ES module, and is not used as a regular key of `module.exports`.
830
- if ( prop in target || prop === '__esModule' ) return target [ prop ] ;
843
+ if ( prop in target || prop === '__esModule' ) { return target [ prop ] ; }
831
844
emitCircularRequireWarning ( prop ) ;
832
845
return undefined ;
833
846
} ,
834
847
835
848
getOwnPropertyDescriptor ( target , prop ) {
836
- if ( ObjectPrototypeHasOwnProperty ( target , prop ) || prop === '__esModule' )
849
+ if ( ObjectPrototypeHasOwnProperty ( target , prop ) || prop === '__esModule' ) {
837
850
return ObjectGetOwnPropertyDescriptor ( target , prop ) ;
851
+ }
838
852
emitCircularRequireWarning ( prop ) ;
839
853
return undefined ;
840
854
} ,
@@ -878,8 +892,9 @@ Module._load = function(request, parent, isMain) {
878
892
const cachedModule = Module . _cache [ filename ] ;
879
893
if ( cachedModule !== undefined ) {
880
894
updateChildren ( parent , cachedModule , true ) ;
881
- if ( ! cachedModule . loaded )
895
+ if ( ! cachedModule . loaded ) {
882
896
return getExportsForCircularRequire ( cachedModule ) ;
897
+ }
883
898
return cachedModule . exports ;
884
899
}
885
900
delete relativeResolveCache [ relResolveCacheIdentifier ] ;
@@ -904,8 +919,9 @@ Module._load = function(request, parent, isMain) {
904
919
updateChildren ( parent , cachedModule , true ) ;
905
920
if ( ! cachedModule . loaded ) {
906
921
const parseCachedModule = cjsParseCache . get ( cachedModule ) ;
907
- if ( ! parseCachedModule || parseCachedModule . loaded )
922
+ if ( ! parseCachedModule || parseCachedModule . loaded ) {
908
923
return getExportsForCircularRequire ( cachedModule ) ;
924
+ }
909
925
parseCachedModule . loaded = true ;
910
926
} else {
911
927
return cachedModule . exports ;
@@ -988,8 +1004,9 @@ Module._resolveFilename = function(request, parent, isMain, options) {
988
1004
const lookupPaths = Module . _resolveLookupPaths ( request , fakeParent ) ;
989
1005
990
1006
for ( let j = 0 ; j < lookupPaths . length ; j ++ ) {
991
- if ( ! ArrayPrototypeIncludes ( paths , lookupPaths [ j ] ) )
1007
+ if ( ! ArrayPrototypeIncludes ( paths , lookupPaths [ j ] ) ) {
992
1008
ArrayPrototypePush ( paths , lookupPaths [ j ] ) ;
1009
+ }
993
1010
}
994
1011
}
995
1012
}
@@ -1013,8 +1030,9 @@ Module._resolveFilename = function(request, parent, isMain, options) {
1013
1030
getCjsConditions ( ) ) , parentPath ,
1014
1031
pkg . path ) ;
1015
1032
} catch ( e ) {
1016
- if ( e . code === 'ERR_MODULE_NOT_FOUND' )
1033
+ if ( e . code === 'ERR_MODULE_NOT_FOUND' ) {
1017
1034
throw createEsmNotFoundErr ( request ) ;
1035
+ }
1018
1036
throw e ;
1019
1037
}
1020
1038
}
@@ -1032,7 +1050,7 @@ Module._resolveFilename = function(request, parent, isMain, options) {
1032
1050
1033
1051
// Look up the filename first, since that's the cache key.
1034
1052
const filename = Module . _findPath ( request , paths , isMain ) ;
1035
- if ( filename ) return filename ;
1053
+ if ( filename ) { return filename ; }
1036
1054
const requireStack = [ ] ;
1037
1055
for ( let cursor = parent ;
1038
1056
cursor ;
@@ -1053,13 +1071,15 @@ Module._resolveFilename = function(request, parent, isMain, options) {
1053
1071
1054
1072
function finalizeEsmResolution ( resolved , parentPath , pkgPath ) {
1055
1073
const { encodedSepRegEx } = require ( 'internal/modules/esm/resolve' ) ;
1056
- if ( RegExpPrototypeExec ( encodedSepRegEx , resolved ) !== null )
1074
+ if ( RegExpPrototypeExec ( encodedSepRegEx , resolved ) !== null ) {
1057
1075
throw new ERR_INVALID_MODULE_SPECIFIER (
1058
1076
resolved , 'must not include encoded "/" or "\\" characters' , parentPath ) ;
1077
+ }
1059
1078
const filename = fileURLToPath ( resolved ) ;
1060
1079
const actual = tryFile ( filename ) ;
1061
- if ( actual )
1080
+ if ( actual ) {
1062
1081
return actual ;
1082
+ }
1063
1083
const err = createEsmNotFoundErr ( filename ,
1064
1084
path . resolve ( pkgPath , 'package.json' ) ) ;
1065
1085
throw err ;
@@ -1069,8 +1089,9 @@ function createEsmNotFoundErr(request, path) {
1069
1089
// eslint-disable-next-line no-restricted-syntax
1070
1090
const err = new Error ( `Cannot find module '${ request } '` ) ;
1071
1091
err . code = 'MODULE_NOT_FOUND' ;
1072
- if ( path )
1092
+ if ( path ) {
1073
1093
err . path = path ;
1094
+ }
1074
1095
// TODO(BridgeAR): Add the requireStack as well.
1075
1096
return err ;
1076
1097
}
@@ -1085,8 +1106,9 @@ Module.prototype.load = function(filename) {
1085
1106
1086
1107
const extension = findLongestRegisteredExtension ( filename ) ;
1087
1108
// allow .mjs to be overridden
1088
- if ( StringPrototypeEndsWith ( filename , '.mjs' ) && ! Module . _extensions [ '.mjs' ] )
1109
+ if ( StringPrototypeEndsWith ( filename , '.mjs' ) && ! Module . _extensions [ '.mjs' ] ) {
1089
1110
throw new ERR_REQUIRE_ESM ( filename , true ) ;
1111
+ }
1090
1112
1091
1113
Module . _extensions [ extension ] ( this , filename ) ;
1092
1114
this . loaded = true ;
@@ -1097,8 +1119,9 @@ Module.prototype.load = function(filename) {
1097
1119
// Preemptively cache
1098
1120
if ( ( module ?. module === undefined ||
1099
1121
module . module . getStatus ( ) < kEvaluated ) &&
1100
- ! cascadedLoader . cjsCache . has ( this ) )
1122
+ ! cascadedLoader . cjsCache . has ( this ) ) {
1101
1123
cascadedLoader . cjsCache . set ( this , exports ) ;
1124
+ }
1102
1125
} ;
1103
1126
1104
1127
// Loads a module at the given file path. Returns that module's
@@ -1233,7 +1256,7 @@ Module.prototype._compile = function(content, filename) {
1233
1256
const exports = this . exports ;
1234
1257
const thisValue = exports ;
1235
1258
const module = this ;
1236
- if ( requireDepth === 0 ) statCache = new SafeMap ( ) ;
1259
+ if ( requireDepth === 0 ) { statCache = new SafeMap ( ) ; }
1237
1260
if ( inspectorWrapper ) {
1238
1261
result = inspectorWrapper ( compiledWrapper , thisValue , exports ,
1239
1262
require , module , filename , dirname ) ;
@@ -1242,7 +1265,7 @@ Module.prototype._compile = function(content, filename) {
1242
1265
[ exports , require , module , filename , dirname ] ) ;
1243
1266
}
1244
1267
hasLoadedAnyUserCJSModule = true ;
1245
- if ( requireDepth === 0 ) statCache = null ;
1268
+ if ( requireDepth === 0 ) { statCache = null ; }
1246
1269
return result ;
1247
1270
} ;
1248
1271
@@ -1399,8 +1422,7 @@ Module._initPaths = function() {
1399
1422
} ;
1400
1423
1401
1424
Module . _preloadModules = function ( requests ) {
1402
- if ( ! ArrayIsArray ( requests ) )
1403
- return ;
1425
+ if ( ! ArrayIsArray ( requests ) ) { return ; }
1404
1426
1405
1427
isPreloading = true ;
1406
1428
@@ -1416,8 +1438,9 @@ Module._preloadModules = function(requests) {
1416
1438
throw e ;
1417
1439
}
1418
1440
}
1419
- for ( let n = 0 ; n < requests . length ; n ++ )
1441
+ for ( let n = 0 ; n < requests . length ; n ++ ) {
1420
1442
internalRequire ( parent , requests [ n ] ) ;
1443
+ }
1421
1444
isPreloading = false ;
1422
1445
} ;
1423
1446
0 commit comments