@@ -172,7 +172,7 @@ function stat(filename) {
172
172
filename = path . toNamespacedPath ( filename ) ;
173
173
if ( statCache !== null ) {
174
174
const result = statCache . get ( filename ) ;
175
- if ( result !== undefined ) return result ;
175
+ if ( result !== undefined ) { return result ; }
176
176
}
177
177
const result = internalModuleStat ( filename ) ;
178
178
if ( statCache !== null && result >= 0 ) {
@@ -196,8 +196,9 @@ ObjectDefineProperty(Module, '_stat', {
196
196
197
197
function updateChildren ( parent , child , scan ) {
198
198
const children = parent ?. children ;
199
- if ( children && ! ( scan && ArrayPrototypeIncludes ( children , child ) ) )
199
+ if ( children && ! ( scan && ArrayPrototypeIncludes ( children , child ) ) ) {
200
200
ArrayPrototypePush ( children , child ) ;
201
+ }
201
202
}
202
203
203
204
function reportModuleToWatchMode ( filename ) {
@@ -379,13 +380,16 @@ function readPackageScope(checkPath) {
379
380
do {
380
381
separatorIndex = StringPrototypeLastIndexOf ( checkPath , sep ) ;
381
382
checkPath = StringPrototypeSlice ( checkPath , 0 , separatorIndex ) ;
382
- if ( StringPrototypeEndsWith ( checkPath , sep + 'node_modules' ) )
383
+ if ( StringPrototypeEndsWith ( checkPath , sep + 'node_modules' ) ) {
383
384
return false ;
385
+ }
384
386
const pjson = _readPackage ( checkPath + sep ) ;
385
- if ( pjson . exists ) return {
386
- data : pjson ,
387
- path : checkPath ,
388
- } ;
387
+ if ( pjson . exists ) {
388
+ return {
389
+ data : pjson ,
390
+ path : checkPath ,
391
+ } ;
392
+ }
389
393
} while ( separatorIndex > rootSeparatorIndex ) ;
390
394
return false ;
391
395
}
@@ -438,7 +442,7 @@ const realpathCache = new SafeMap();
438
442
// absolute realpath.
439
443
function tryFile ( requestPath , isMain ) {
440
444
const rc = _stat ( requestPath ) ;
441
- if ( rc !== 0 ) return ;
445
+ if ( rc !== 0 ) { return ; }
442
446
if ( getOptionValue ( '--preserve-symlinks' ) && ! isMain ) {
443
447
return path . resolve ( requestPath ) ;
444
448
}
@@ -472,15 +476,15 @@ function findLongestRegisteredExtension(filename) {
472
476
let startIndex = 0 ;
473
477
while ( ( index = StringPrototypeIndexOf ( name , '.' , startIndex ) ) !== - 1 ) {
474
478
startIndex = index + 1 ;
475
- if ( index === 0 ) continue ; // Skip dotfiles like .gitignore
479
+ if ( index === 0 ) { continue ; } // Skip dotfiles like .gitignore
476
480
currentExtension = StringPrototypeSlice ( name , index ) ;
477
- if ( Module . _extensions [ currentExtension ] ) return currentExtension ;
481
+ if ( Module . _extensions [ currentExtension ] ) { return currentExtension ; }
478
482
}
479
483
return '.js' ;
480
484
}
481
485
482
486
function trySelfParentPath ( parent ) {
483
- if ( ! parent ) return false ;
487
+ if ( ! parent ) { return false ; }
484
488
485
489
if ( parent . filename ) {
486
490
return parent . filename ;
@@ -494,7 +498,7 @@ function trySelfParentPath(parent) {
494
498
}
495
499
496
500
function trySelf ( parentPath , request ) {
497
- if ( ! parentPath ) return false ;
501
+ if ( ! parentPath ) { return false ; }
498
502
499
503
const { data : pkg , path : pkgPath } = readPackageScope ( parentPath ) ;
500
504
if ( ! pkg || pkg . exports == null || pkg . name === undefined ) {
@@ -516,8 +520,9 @@ function trySelf(parentPath, request) {
516
520
pathToFileURL ( pkgPath + '/package.json' ) , expansion , pkg ,
517
521
pathToFileURL ( parentPath ) , getCjsConditions ( ) ) , parentPath , pkgPath ) ;
518
522
} catch ( e ) {
519
- if ( e . code === 'ERR_MODULE_NOT_FOUND' )
523
+ if ( e . code === 'ERR_MODULE_NOT_FOUND' ) {
520
524
throw createEsmNotFoundErr ( request , pkgPath + '/package.json' ) ;
525
+ }
521
526
throw e ;
522
527
}
523
528
}
@@ -530,8 +535,7 @@ function resolveExports(nmPath, request) {
530
535
// The implementation's behavior is meant to mirror resolution in ESM.
531
536
const { 1 : name , 2 : expansion = '' } =
532
537
RegExpPrototypeExec ( EXPORTS_PATTERN , request ) || kEmptyObject ;
533
- if ( ! name )
534
- return ;
538
+ if ( ! name ) { return ; }
535
539
const pkgPath = path . resolve ( nmPath , name ) ;
536
540
const pkg = _readPackage ( pkgPath ) ;
537
541
if ( pkg . exists && pkg . exports != null ) {
@@ -541,8 +545,9 @@ function resolveExports(nmPath, request) {
541
545
pathToFileURL ( pkgPath + '/package.json' ) , '.' + expansion , pkg , null ,
542
546
getCjsConditions ( ) ) , null , pkgPath ) ;
543
547
} catch ( e ) {
544
- if ( e . code === 'ERR_MODULE_NOT_FOUND' )
548
+ if ( e . code === 'ERR_MODULE_NOT_FOUND' ) {
545
549
throw createEsmNotFoundErr ( request , pkgPath + '/package.json' ) ;
550
+ }
546
551
throw e ;
547
552
}
548
553
}
@@ -564,8 +569,9 @@ Module._findPath = function(request, paths, isMain) {
564
569
565
570
const cacheKey = request + '\x00' + ArrayPrototypeJoin ( paths , '\x00' ) ;
566
571
const entry = Module . _pathCache [ cacheKey ] ;
567
- if ( entry )
572
+ if ( entry ) {
568
573
return entry ;
574
+ }
569
575
570
576
let exts ;
571
577
const trailingSlash = request . length > 0 &&
@@ -603,12 +609,15 @@ Module._findPath = function(request, paths, isMain) {
603
609
for ( let i = 0 ; i < paths . length ; i ++ ) {
604
610
// Don't search further if path doesn't exist and request is inside the path
605
611
const curPath = paths [ i ] ;
606
- if ( insidePath && curPath && _stat ( curPath ) < 1 ) continue ;
612
+ if ( insidePath && curPath && _stat ( curPath ) < 1 ) {
613
+ continue ;
614
+ }
607
615
608
616
if ( ! absoluteRequest ) {
609
617
const exportsResolved = resolveExports ( curPath , request ) ;
610
- if ( exportsResolved )
618
+ if ( exportsResolved ) {
611
619
return exportsResolved ;
620
+ }
612
621
}
613
622
614
623
const basePath = path . resolve ( curPath , request ) ;
@@ -640,16 +649,18 @@ Module._findPath = function(request, paths, isMain) {
640
649
641
650
if ( ! filename ) {
642
651
// Try it with each of the extensions
643
- if ( exts === undefined )
652
+ if ( exts === undefined ) {
644
653
exts = ObjectKeys ( Module . _extensions ) ;
654
+ }
645
655
filename = tryExtensions ( basePath , exts , isMain ) ;
646
656
}
647
657
}
648
658
649
659
if ( ! filename && rc === 1 ) { // Directory.
650
660
// try it with each of the extensions at "index"
651
- if ( exts === undefined )
661
+ if ( exts === undefined ) {
652
662
exts = ObjectKeys ( Module . _extensions ) ;
663
+ }
653
664
filename = tryPackage ( basePath , exts , isMain , request ) ;
654
665
}
655
666
@@ -685,8 +696,9 @@ if (isWindows) {
685
696
// path.resolve will make sure from.length >=3 in Windows.
686
697
if ( StringPrototypeCharCodeAt ( from , from . length - 1 ) ===
687
698
CHAR_BACKWARD_SLASH &&
688
- StringPrototypeCharCodeAt ( from , from . length - 2 ) === CHAR_COLON )
699
+ StringPrototypeCharCodeAt ( from , from . length - 2 ) === CHAR_COLON ) {
689
700
return [ from + 'node_modules' ] ;
701
+ }
690
702
691
703
const paths = [ ] ;
692
704
for ( let i = from . length - 1 , p = 0 , last = from . length ; i >= 0 ; -- i ) {
@@ -699,11 +711,12 @@ if (isWindows) {
699
711
if ( code === CHAR_BACKWARD_SLASH ||
700
712
code === CHAR_FORWARD_SLASH ||
701
713
code === CHAR_COLON ) {
702
- if ( p !== nmLen )
714
+ if ( p !== nmLen ) {
703
715
ArrayPrototypePush (
704
716
paths ,
705
717
StringPrototypeSlice ( from , 0 , last ) + '\\node_modules' ,
706
718
) ;
719
+ }
707
720
last = i ;
708
721
p = 0 ;
709
722
} else if ( p !== - 1 ) {
@@ -724,8 +737,9 @@ if (isWindows) {
724
737
from = path . resolve ( from ) ;
725
738
// Return early not only to avoid unnecessary work, but to *avoid* returning
726
739
// an array of two items for a root: [ '//node_modules', '/node_modules' ]
727
- if ( from === '/' )
740
+ if ( from === '/' ) {
728
741
return [ '/node_modules' ] ;
742
+ }
729
743
730
744
// note: this approach *only* works when the path is guaranteed
731
745
// to be absolute. Doing a fully-edge-case-correct path.split
@@ -734,11 +748,12 @@ if (isWindows) {
734
748
for ( let i = from . length - 1 , p = 0 , last = from . length ; i >= 0 ; -- i ) {
735
749
const code = StringPrototypeCharCodeAt ( from , i ) ;
736
750
if ( code === CHAR_FORWARD_SLASH ) {
737
- if ( p !== nmLen )
751
+ if ( p !== nmLen ) {
738
752
ArrayPrototypePush (
739
753
paths ,
740
754
StringPrototypeSlice ( from , 0 , last ) + '/node_modules' ,
741
755
) ;
756
+ }
742
757
last = i ;
743
758
p = 0 ;
744
759
} else if ( p !== - 1 ) {
@@ -815,14 +830,15 @@ const CircularRequirePrototypeWarningProxy = new Proxy({}, {
815
830
// Allow __esModule access in any case because it is used in the output
816
831
// of transpiled code to determine whether something comes from an
817
832
// ES module, and is not used as a regular key of `module.exports`.
818
- if ( prop in target || prop === '__esModule' ) return target [ prop ] ;
833
+ if ( prop in target || prop === '__esModule' ) { return target [ prop ] ; }
819
834
emitCircularRequireWarning ( prop ) ;
820
835
return undefined ;
821
836
} ,
822
837
823
838
getOwnPropertyDescriptor ( target , prop ) {
824
- if ( ObjectPrototypeHasOwnProperty ( target , prop ) || prop === '__esModule' )
839
+ if ( ObjectPrototypeHasOwnProperty ( target , prop ) || prop === '__esModule' ) {
825
840
return ObjectGetOwnPropertyDescriptor ( target , prop ) ;
841
+ }
826
842
emitCircularRequireWarning ( prop ) ;
827
843
return undefined ;
828
844
} ,
@@ -866,8 +882,9 @@ Module._load = function(request, parent, isMain) {
866
882
const cachedModule = Module . _cache [ filename ] ;
867
883
if ( cachedModule !== undefined ) {
868
884
updateChildren ( parent , cachedModule , true ) ;
869
- if ( ! cachedModule . loaded )
885
+ if ( ! cachedModule . loaded ) {
870
886
return getExportsForCircularRequire ( cachedModule ) ;
887
+ }
871
888
return cachedModule . exports ;
872
889
}
873
890
delete relativeResolveCache [ relResolveCacheIdentifier ] ;
@@ -892,8 +909,9 @@ Module._load = function(request, parent, isMain) {
892
909
updateChildren ( parent , cachedModule , true ) ;
893
910
if ( ! cachedModule . loaded ) {
894
911
const parseCachedModule = cjsParseCache . get ( cachedModule ) ;
895
- if ( ! parseCachedModule || parseCachedModule . loaded )
912
+ if ( ! parseCachedModule || parseCachedModule . loaded ) {
896
913
return getExportsForCircularRequire ( cachedModule ) ;
914
+ }
897
915
parseCachedModule . loaded = true ;
898
916
} else {
899
917
return cachedModule . exports ;
@@ -976,8 +994,9 @@ Module._resolveFilename = function(request, parent, isMain, options) {
976
994
const lookupPaths = Module . _resolveLookupPaths ( request , fakeParent ) ;
977
995
978
996
for ( let j = 0 ; j < lookupPaths . length ; j ++ ) {
979
- if ( ! ArrayPrototypeIncludes ( paths , lookupPaths [ j ] ) )
997
+ if ( ! ArrayPrototypeIncludes ( paths , lookupPaths [ j ] ) ) {
980
998
ArrayPrototypePush ( paths , lookupPaths [ j ] ) ;
999
+ }
981
1000
}
982
1001
}
983
1002
}
@@ -1001,8 +1020,9 @@ Module._resolveFilename = function(request, parent, isMain, options) {
1001
1020
getCjsConditions ( ) ) , parentPath ,
1002
1021
pkg . path ) ;
1003
1022
} catch ( e ) {
1004
- if ( e . code === 'ERR_MODULE_NOT_FOUND' )
1023
+ if ( e . code === 'ERR_MODULE_NOT_FOUND' ) {
1005
1024
throw createEsmNotFoundErr ( request ) ;
1025
+ }
1006
1026
throw e ;
1007
1027
}
1008
1028
}
@@ -1020,7 +1040,7 @@ Module._resolveFilename = function(request, parent, isMain, options) {
1020
1040
1021
1041
// Look up the filename first, since that's the cache key.
1022
1042
const filename = Module . _findPath ( request , paths , isMain ) ;
1023
- if ( filename ) return filename ;
1043
+ if ( filename ) { return filename ; }
1024
1044
const requireStack = [ ] ;
1025
1045
for ( let cursor = parent ;
1026
1046
cursor ;
@@ -1041,13 +1061,15 @@ Module._resolveFilename = function(request, parent, isMain, options) {
1041
1061
1042
1062
function finalizeEsmResolution ( resolved , parentPath , pkgPath ) {
1043
1063
const { encodedSepRegEx } = require ( 'internal/modules/esm/resolve' ) ;
1044
- if ( RegExpPrototypeExec ( encodedSepRegEx , resolved ) !== null )
1064
+ if ( RegExpPrototypeExec ( encodedSepRegEx , resolved ) !== null ) {
1045
1065
throw new ERR_INVALID_MODULE_SPECIFIER (
1046
1066
resolved , 'must not include encoded "/" or "\\" characters' , parentPath ) ;
1067
+ }
1047
1068
const filename = fileURLToPath ( resolved ) ;
1048
1069
const actual = tryFile ( filename ) ;
1049
- if ( actual )
1070
+ if ( actual ) {
1050
1071
return actual ;
1072
+ }
1051
1073
const err = createEsmNotFoundErr ( filename ,
1052
1074
path . resolve ( pkgPath , 'package.json' ) ) ;
1053
1075
throw err ;
@@ -1057,8 +1079,9 @@ function createEsmNotFoundErr(request, path) {
1057
1079
// eslint-disable-next-line no-restricted-syntax
1058
1080
const err = new Error ( `Cannot find module '${ request } '` ) ;
1059
1081
err . code = 'MODULE_NOT_FOUND' ;
1060
- if ( path )
1082
+ if ( path ) {
1061
1083
err . path = path ;
1084
+ }
1062
1085
// TODO(BridgeAR): Add the requireStack as well.
1063
1086
return err ;
1064
1087
}
@@ -1073,8 +1096,9 @@ Module.prototype.load = function(filename) {
1073
1096
1074
1097
const extension = findLongestRegisteredExtension ( filename ) ;
1075
1098
// allow .mjs to be overridden
1076
- if ( StringPrototypeEndsWith ( filename , '.mjs' ) && ! Module . _extensions [ '.mjs' ] )
1099
+ if ( StringPrototypeEndsWith ( filename , '.mjs' ) && ! Module . _extensions [ '.mjs' ] ) {
1077
1100
throw new ERR_REQUIRE_ESM ( filename , true ) ;
1101
+ }
1078
1102
1079
1103
Module . _extensions [ extension ] ( this , filename ) ;
1080
1104
this . loaded = true ;
@@ -1085,8 +1109,9 @@ Module.prototype.load = function(filename) {
1085
1109
// Preemptively cache
1086
1110
if ( ( module ?. module === undefined ||
1087
1111
module . module . getStatus ( ) < kEvaluated ) &&
1088
- ! cascadedLoader . cjsCache . has ( this ) )
1112
+ ! cascadedLoader . cjsCache . has ( this ) ) {
1089
1113
cascadedLoader . cjsCache . set ( this , exports ) ;
1114
+ }
1090
1115
} ;
1091
1116
1092
1117
// Loads a module at the given file path. Returns that module's
@@ -1213,7 +1238,7 @@ Module.prototype._compile = function(content, filename) {
1213
1238
const exports = this . exports ;
1214
1239
const thisValue = exports ;
1215
1240
const module = this ;
1216
- if ( requireDepth === 0 ) statCache = new SafeMap ( ) ;
1241
+ if ( requireDepth === 0 ) { statCache = new SafeMap ( ) ; }
1217
1242
if ( inspectorWrapper ) {
1218
1243
result = inspectorWrapper ( compiledWrapper , thisValue , exports ,
1219
1244
require , module , filename , dirname ) ;
@@ -1222,7 +1247,7 @@ Module.prototype._compile = function(content, filename) {
1222
1247
[ exports , require , module , filename , dirname ] ) ;
1223
1248
}
1224
1249
hasLoadedAnyUserCJSModule = true ;
1225
- if ( requireDepth === 0 ) statCache = null ;
1250
+ if ( requireDepth === 0 ) { statCache = null ; }
1226
1251
return result ;
1227
1252
} ;
1228
1253
@@ -1379,8 +1404,7 @@ Module._initPaths = function() {
1379
1404
} ;
1380
1405
1381
1406
Module . _preloadModules = function ( requests ) {
1382
- if ( ! ArrayIsArray ( requests ) )
1383
- return ;
1407
+ if ( ! ArrayIsArray ( requests ) ) { return ; }
1384
1408
1385
1409
isPreloading = true ;
1386
1410
@@ -1396,8 +1420,9 @@ Module._preloadModules = function(requests) {
1396
1420
throw e ;
1397
1421
}
1398
1422
}
1399
- for ( let n = 0 ; n < requests . length ; n ++ )
1423
+ for ( let n = 0 ; n < requests . length ; n ++ ) {
1400
1424
internalRequire ( parent , requests [ n ] ) ;
1425
+ }
1401
1426
isPreloading = false ;
1402
1427
} ;
1403
1428
0 commit comments