@@ -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,7 @@ 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 ) ) )
201
- ArrayPrototypePush ( children , child ) ;
200
+ if ( children && ! ( scan && ArrayPrototypeIncludes ( children , child ) ) ) { ArrayPrototypePush ( children , child ) ; }
202
201
}
203
202
204
203
function reportModuleToWatchMode ( filename ) {
@@ -386,13 +385,14 @@ function readPackageScope(checkPath) {
386
385
if ( enabledPermission && ! permission . has ( 'fs.read' , checkPath + sep ) ) {
387
386
return false ;
388
387
}
389
- if ( StringPrototypeEndsWith ( checkPath , sep + 'node_modules' ) )
390
- return false ;
388
+ if ( StringPrototypeEndsWith ( checkPath , sep + 'node_modules' ) ) { return false ; }
391
389
const pjson = _readPackage ( checkPath + sep ) ;
392
- if ( pjson . exists ) return {
393
- data : pjson ,
394
- path : checkPath ,
395
- } ;
390
+ if ( pjson . exists ) {
391
+ return {
392
+ data : pjson ,
393
+ path : checkPath ,
394
+ } ;
395
+ }
396
396
} while ( separatorIndex > rootSeparatorIndex ) ;
397
397
return false ;
398
398
}
@@ -445,7 +445,7 @@ const realpathCache = new SafeMap();
445
445
// absolute realpath.
446
446
function tryFile ( requestPath , isMain ) {
447
447
const rc = _stat ( requestPath ) ;
448
- if ( rc !== 0 ) return ;
448
+ if ( rc !== 0 ) { return ; }
449
449
if ( getOptionValue ( '--preserve-symlinks' ) && ! isMain ) {
450
450
return path . resolve ( requestPath ) ;
451
451
}
@@ -479,15 +479,15 @@ function findLongestRegisteredExtension(filename) {
479
479
let startIndex = 0 ;
480
480
while ( ( index = StringPrototypeIndexOf ( name , '.' , startIndex ) ) !== - 1 ) {
481
481
startIndex = index + 1 ;
482
- if ( index === 0 ) continue ; // Skip dotfiles like .gitignore
482
+ if ( index === 0 ) { continue ; } // Skip dotfiles like .gitignore
483
483
currentExtension = StringPrototypeSlice ( name , index ) ;
484
- if ( Module . _extensions [ currentExtension ] ) return currentExtension ;
484
+ if ( Module . _extensions [ currentExtension ] ) { return currentExtension ; }
485
485
}
486
486
return '.js' ;
487
487
}
488
488
489
489
function trySelfParentPath ( parent ) {
490
- if ( ! parent ) return false ;
490
+ if ( ! parent ) { return false ; }
491
491
492
492
if ( parent . filename ) {
493
493
return parent . filename ;
@@ -501,7 +501,7 @@ function trySelfParentPath(parent) {
501
501
}
502
502
503
503
function trySelf ( parentPath , request ) {
504
- if ( ! parentPath ) return false ;
504
+ if ( ! parentPath ) { return false ; }
505
505
506
506
const { data : pkg , path : pkgPath } = readPackageScope ( parentPath ) ;
507
507
if ( ! pkg || pkg . exports == null || pkg . name === undefined ) {
@@ -523,8 +523,7 @@ function trySelf(parentPath, request) {
523
523
pathToFileURL ( pkgPath + '/package.json' ) , expansion , pkg ,
524
524
pathToFileURL ( parentPath ) , getCjsConditions ( ) ) , parentPath , pkgPath ) ;
525
525
} catch ( e ) {
526
- if ( e . code === 'ERR_MODULE_NOT_FOUND' )
527
- throw createEsmNotFoundErr ( request , pkgPath + '/package.json' ) ;
526
+ if ( e . code === 'ERR_MODULE_NOT_FOUND' ) { throw createEsmNotFoundErr ( request , pkgPath + '/package.json' ) ; }
528
527
throw e ;
529
528
}
530
529
}
@@ -537,8 +536,7 @@ function resolveExports(nmPath, request) {
537
536
// The implementation's behavior is meant to mirror resolution in ESM.
538
537
const { 1 : name , 2 : expansion = '' } =
539
538
RegExpPrototypeExec ( EXPORTS_PATTERN , request ) || kEmptyObject ;
540
- if ( ! name )
541
- return ;
539
+ if ( ! name ) { return ; }
542
540
const pkgPath = path . resolve ( nmPath , name ) ;
543
541
const pkg = _readPackage ( pkgPath ) ;
544
542
if ( pkg . exists && pkg . exports != null ) {
@@ -548,8 +546,7 @@ function resolveExports(nmPath, request) {
548
546
pathToFileURL ( pkgPath + '/package.json' ) , '.' + expansion , pkg , null ,
549
547
getCjsConditions ( ) ) , null , pkgPath ) ;
550
548
} catch ( e ) {
551
- if ( e . code === 'ERR_MODULE_NOT_FOUND' )
552
- throw createEsmNotFoundErr ( request , pkgPath + '/package.json' ) ;
549
+ if ( e . code === 'ERR_MODULE_NOT_FOUND' ) { throw createEsmNotFoundErr ( request , pkgPath + '/package.json' ) ; }
553
550
throw e ;
554
551
}
555
552
}
@@ -571,8 +568,7 @@ Module._findPath = function(request, paths, isMain) {
571
568
572
569
const cacheKey = request + '\x00' + ArrayPrototypeJoin ( paths , '\x00' ) ;
573
570
const entry = Module . _pathCache [ cacheKey ] ;
574
- if ( entry )
575
- return entry ;
571
+ if ( entry ) { return entry ; }
576
572
577
573
let exts ;
578
574
const trailingSlash = request . length > 0 &&
@@ -619,8 +615,7 @@ Module._findPath = function(request, paths, isMain) {
619
615
620
616
if ( ! absoluteRequest ) {
621
617
const exportsResolved = resolveExports ( curPath , request ) ;
622
- if ( exportsResolved )
623
- return exportsResolved ;
618
+ if ( exportsResolved ) { return exportsResolved ; }
624
619
}
625
620
626
621
const basePath = path . resolve ( curPath , request ) ;
@@ -652,16 +647,14 @@ Module._findPath = function(request, paths, isMain) {
652
647
653
648
if ( ! filename ) {
654
649
// Try it with each of the extensions
655
- if ( exts === undefined )
656
- exts = ObjectKeys ( Module . _extensions ) ;
650
+ if ( exts === undefined ) { exts = ObjectKeys ( Module . _extensions ) ; }
657
651
filename = tryExtensions ( basePath , exts , isMain ) ;
658
652
}
659
653
}
660
654
661
655
if ( ! filename && rc === 1 ) { // Directory.
662
656
// try it with each of the extensions at "index"
663
- if ( exts === undefined )
664
- exts = ObjectKeys ( Module . _extensions ) ;
657
+ if ( exts === undefined ) { exts = ObjectKeys ( Module . _extensions ) ; }
665
658
filename = tryPackage ( basePath , exts , isMain , request ) ;
666
659
}
667
660
@@ -697,8 +690,7 @@ if (isWindows) {
697
690
// path.resolve will make sure from.length >=3 in Windows.
698
691
if ( StringPrototypeCharCodeAt ( from , from . length - 1 ) ===
699
692
CHAR_BACKWARD_SLASH &&
700
- StringPrototypeCharCodeAt ( from , from . length - 2 ) === CHAR_COLON )
701
- return [ from + 'node_modules' ] ;
693
+ StringPrototypeCharCodeAt ( from , from . length - 2 ) === CHAR_COLON ) { return [ from + 'node_modules' ] ; }
702
694
703
695
const paths = [ ] ;
704
696
for ( let i = from . length - 1 , p = 0 , last = from . length ; i >= 0 ; -- i ) {
@@ -711,11 +703,12 @@ if (isWindows) {
711
703
if ( code === CHAR_BACKWARD_SLASH ||
712
704
code === CHAR_FORWARD_SLASH ||
713
705
code === CHAR_COLON ) {
714
- if ( p !== nmLen )
706
+ if ( p !== nmLen ) {
715
707
ArrayPrototypePush (
716
708
paths ,
717
709
StringPrototypeSlice ( from , 0 , last ) + '\\node_modules' ,
718
710
) ;
711
+ }
719
712
last = i ;
720
713
p = 0 ;
721
714
} else if ( p !== - 1 ) {
@@ -736,8 +729,7 @@ if (isWindows) {
736
729
from = path . resolve ( from ) ;
737
730
// Return early not only to avoid unnecessary work, but to *avoid* returning
738
731
// an array of two items for a root: [ '//node_modules', '/node_modules' ]
739
- if ( from === '/' )
740
- return [ '/node_modules' ] ;
732
+ if ( from === '/' ) { return [ '/node_modules' ] ; }
741
733
742
734
// note: this approach *only* works when the path is guaranteed
743
735
// to be absolute. Doing a fully-edge-case-correct path.split
@@ -746,11 +738,12 @@ if (isWindows) {
746
738
for ( let i = from . length - 1 , p = 0 , last = from . length ; i >= 0 ; -- i ) {
747
739
const code = StringPrototypeCharCodeAt ( from , i ) ;
748
740
if ( code === CHAR_FORWARD_SLASH ) {
749
- if ( p !== nmLen )
741
+ if ( p !== nmLen ) {
750
742
ArrayPrototypePush (
751
743
paths ,
752
744
StringPrototypeSlice ( from , 0 , last ) + '/node_modules' ,
753
745
) ;
746
+ }
754
747
last = i ;
755
748
p = 0 ;
756
749
} else if ( p !== - 1 ) {
@@ -827,14 +820,15 @@ const CircularRequirePrototypeWarningProxy = new Proxy({}, {
827
820
// Allow __esModule access in any case because it is used in the output
828
821
// of transpiled code to determine whether something comes from an
829
822
// ES module, and is not used as a regular key of `module.exports`.
830
- if ( prop in target || prop === '__esModule' ) return target [ prop ] ;
823
+ if ( prop in target || prop === '__esModule' ) { return target [ prop ] ; }
831
824
emitCircularRequireWarning ( prop ) ;
832
825
return undefined ;
833
826
} ,
834
827
835
828
getOwnPropertyDescriptor ( target , prop ) {
836
- if ( ObjectPrototypeHasOwnProperty ( target , prop ) || prop === '__esModule' )
829
+ if ( ObjectPrototypeHasOwnProperty ( target , prop ) || prop === '__esModule' ) {
837
830
return ObjectGetOwnPropertyDescriptor ( target , prop ) ;
831
+ }
838
832
emitCircularRequireWarning ( prop ) ;
839
833
return undefined ;
840
834
} ,
@@ -878,8 +872,7 @@ Module._load = function(request, parent, isMain) {
878
872
const cachedModule = Module . _cache [ filename ] ;
879
873
if ( cachedModule !== undefined ) {
880
874
updateChildren ( parent , cachedModule , true ) ;
881
- if ( ! cachedModule . loaded )
882
- return getExportsForCircularRequire ( cachedModule ) ;
875
+ if ( ! cachedModule . loaded ) { return getExportsForCircularRequire ( cachedModule ) ; }
883
876
return cachedModule . exports ;
884
877
}
885
878
delete relativeResolveCache [ relResolveCacheIdentifier ] ;
@@ -904,8 +897,7 @@ Module._load = function(request, parent, isMain) {
904
897
updateChildren ( parent , cachedModule , true ) ;
905
898
if ( ! cachedModule . loaded ) {
906
899
const parseCachedModule = cjsParseCache . get ( cachedModule ) ;
907
- if ( ! parseCachedModule || parseCachedModule . loaded )
908
- return getExportsForCircularRequire ( cachedModule ) ;
900
+ if ( ! parseCachedModule || parseCachedModule . loaded ) { return getExportsForCircularRequire ( cachedModule ) ; }
909
901
parseCachedModule . loaded = true ;
910
902
} else {
911
903
return cachedModule . exports ;
@@ -988,8 +980,7 @@ Module._resolveFilename = function(request, parent, isMain, options) {
988
980
const lookupPaths = Module . _resolveLookupPaths ( request , fakeParent ) ;
989
981
990
982
for ( let j = 0 ; j < lookupPaths . length ; j ++ ) {
991
- if ( ! ArrayPrototypeIncludes ( paths , lookupPaths [ j ] ) )
992
- ArrayPrototypePush ( paths , lookupPaths [ j ] ) ;
983
+ if ( ! ArrayPrototypeIncludes ( paths , lookupPaths [ j ] ) ) { ArrayPrototypePush ( paths , lookupPaths [ j ] ) ; }
993
984
}
994
985
}
995
986
}
@@ -1013,8 +1004,7 @@ Module._resolveFilename = function(request, parent, isMain, options) {
1013
1004
getCjsConditions ( ) ) , parentPath ,
1014
1005
pkg . path ) ;
1015
1006
} catch ( e ) {
1016
- if ( e . code === 'ERR_MODULE_NOT_FOUND' )
1017
- throw createEsmNotFoundErr ( request ) ;
1007
+ if ( e . code === 'ERR_MODULE_NOT_FOUND' ) { throw createEsmNotFoundErr ( request ) ; }
1018
1008
throw e ;
1019
1009
}
1020
1010
}
@@ -1032,7 +1022,7 @@ Module._resolveFilename = function(request, parent, isMain, options) {
1032
1022
1033
1023
// Look up the filename first, since that's the cache key.
1034
1024
const filename = Module . _findPath ( request , paths , isMain ) ;
1035
- if ( filename ) return filename ;
1025
+ if ( filename ) { return filename ; }
1036
1026
const requireStack = [ ] ;
1037
1027
for ( let cursor = parent ;
1038
1028
cursor ;
@@ -1053,13 +1043,13 @@ Module._resolveFilename = function(request, parent, isMain, options) {
1053
1043
1054
1044
function finalizeEsmResolution ( resolved , parentPath , pkgPath ) {
1055
1045
const { encodedSepRegEx } = require ( 'internal/modules/esm/resolve' ) ;
1056
- if ( RegExpPrototypeExec ( encodedSepRegEx , resolved ) !== null )
1046
+ if ( RegExpPrototypeExec ( encodedSepRegEx , resolved ) !== null ) {
1057
1047
throw new ERR_INVALID_MODULE_SPECIFIER (
1058
1048
resolved , 'must not include encoded "/" or "\\" characters' , parentPath ) ;
1049
+ }
1059
1050
const filename = fileURLToPath ( resolved ) ;
1060
1051
const actual = tryFile ( filename ) ;
1061
- if ( actual )
1062
- return actual ;
1052
+ if ( actual ) { return actual ; }
1063
1053
const err = createEsmNotFoundErr ( filename ,
1064
1054
path . resolve ( pkgPath , 'package.json' ) ) ;
1065
1055
throw err ;
@@ -1069,8 +1059,7 @@ function createEsmNotFoundErr(request, path) {
1069
1059
// eslint-disable-next-line no-restricted-syntax
1070
1060
const err = new Error ( `Cannot find module '${ request } '` ) ;
1071
1061
err . code = 'MODULE_NOT_FOUND' ;
1072
- if ( path )
1073
- err . path = path ;
1062
+ if ( path ) { err . path = path ; }
1074
1063
// TODO(BridgeAR): Add the requireStack as well.
1075
1064
return err ;
1076
1065
}
@@ -1085,8 +1074,9 @@ Module.prototype.load = function(filename) {
1085
1074
1086
1075
const extension = findLongestRegisteredExtension ( filename ) ;
1087
1076
// allow .mjs to be overridden
1088
- if ( StringPrototypeEndsWith ( filename , '.mjs' ) && ! Module . _extensions [ '.mjs' ] )
1077
+ if ( StringPrototypeEndsWith ( filename , '.mjs' ) && ! Module . _extensions [ '.mjs' ] ) {
1089
1078
throw new ERR_REQUIRE_ESM ( filename , true ) ;
1079
+ }
1090
1080
1091
1081
Module . _extensions [ extension ] ( this , filename ) ;
1092
1082
this . loaded = true ;
@@ -1097,8 +1087,7 @@ Module.prototype.load = function(filename) {
1097
1087
// Preemptively cache
1098
1088
if ( ( module ?. module === undefined ||
1099
1089
module . module . getStatus ( ) < kEvaluated ) &&
1100
- ! cascadedLoader . cjsCache . has ( this ) )
1101
- cascadedLoader . cjsCache . set ( this , exports ) ;
1090
+ ! cascadedLoader . cjsCache . has ( this ) ) { cascadedLoader . cjsCache . set ( this , exports ) ; }
1102
1091
} ;
1103
1092
1104
1093
// Loads a module at the given file path. Returns that module's
@@ -1233,7 +1222,7 @@ Module.prototype._compile = function(content, filename) {
1233
1222
const exports = this . exports ;
1234
1223
const thisValue = exports ;
1235
1224
const module = this ;
1236
- if ( requireDepth === 0 ) statCache = new SafeMap ( ) ;
1225
+ if ( requireDepth === 0 ) { statCache = new SafeMap ( ) ; }
1237
1226
if ( inspectorWrapper ) {
1238
1227
result = inspectorWrapper ( compiledWrapper , thisValue , exports ,
1239
1228
require , module , filename , dirname ) ;
@@ -1242,7 +1231,7 @@ Module.prototype._compile = function(content, filename) {
1242
1231
[ exports , require , module , filename , dirname ] ) ;
1243
1232
}
1244
1233
hasLoadedAnyUserCJSModule = true ;
1245
- if ( requireDepth === 0 ) statCache = null ;
1234
+ if ( requireDepth === 0 ) { statCache = null ; }
1246
1235
return result ;
1247
1236
} ;
1248
1237
@@ -1399,8 +1388,7 @@ Module._initPaths = function() {
1399
1388
} ;
1400
1389
1401
1390
Module . _preloadModules = function ( requests ) {
1402
- if ( ! ArrayIsArray ( requests ) )
1403
- return ;
1391
+ if ( ! ArrayIsArray ( requests ) ) { return ; }
1404
1392
1405
1393
isPreloading = true ;
1406
1394
@@ -1416,8 +1404,7 @@ Module._preloadModules = function(requests) {
1416
1404
throw e ;
1417
1405
}
1418
1406
}
1419
- for ( let n = 0 ; n < requests . length ; n ++ )
1420
- internalRequire ( parent , requests [ n ] ) ;
1407
+ for ( let n = 0 ; n < requests . length ; n ++ ) { internalRequire ( parent , requests [ n ] ) ; }
1421
1408
isPreloading = false ;
1422
1409
} ;
1423
1410
0 commit comments