@@ -173,7 +173,7 @@ function stat(filename) {
173173filename = path . toNamespacedPath ( filename ) ;
174174if ( statCache !== null ) {
175175const result = statCache . get ( filename ) ;
176- if ( result !== undefined ) return result ;
176+ if ( result !== undefined ) { return result ; }
177177}
178178const result = internalModuleStat ( filename ) ;
179179if ( statCache !== null && result >= 0 ) {
@@ -197,8 +197,9 @@ ObjectDefineProperty(Module, '_stat', {
197197
198198function updateChildren ( parent , child , scan ) {
199199const children = parent ?. children ;
200- if ( children && ! ( scan && ArrayPrototypeIncludes ( children , child ) ) )
200+ if ( children && ! ( scan && ArrayPrototypeIncludes ( children , child ) ) ) {
201201ArrayPrototypePush ( children , child ) ;
202+ }
202203}
203204
204205function reportModuleToWatchMode ( filename ) {
@@ -386,13 +387,16 @@ function readPackageScope(checkPath) {
386387if ( enabledPermission && ! permission . has ( 'fs.read' , checkPath + sep ) ) {
387388return false ;
388389}
389- if ( StringPrototypeEndsWith ( checkPath , sep + 'node_modules' ) )
390+ if ( StringPrototypeEndsWith ( checkPath , sep + 'node_modules' ) ) {
390391return false ;
392+ }
391393const 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+ }
396400} while ( separatorIndex > rootSeparatorIndex ) ;
397401return false ;
398402}
@@ -445,7 +449,7 @@ const realpathCache = new SafeMap();
445449// absolute realpath.
446450function tryFile ( requestPath , isMain ) {
447451const rc = _stat ( requestPath ) ;
448- if ( rc !== 0 ) return ;
452+ if ( rc !== 0 ) { return ; }
449453if ( getOptionValue ( '--preserve-symlinks' ) && ! isMain ) {
450454return path . resolve ( requestPath ) ;
451455}
@@ -479,15 +483,15 @@ function findLongestRegisteredExtension(filename) {
479483let startIndex = 0 ;
480484while ( ( index = StringPrototypeIndexOf ( name , '.' , startIndex ) ) !== - 1 ) {
481485startIndex = index + 1 ;
482- if ( index === 0 ) continue ; // Skip dotfiles like .gitignore
486+ if ( index === 0 ) { continue ; } // Skip dotfiles like .gitignore
483487currentExtension = StringPrototypeSlice ( name , index ) ;
484- if ( Module . _extensions [ currentExtension ] ) return currentExtension ;
488+ if ( Module . _extensions [ currentExtension ] ) { return currentExtension ; }
485489}
486490return '.js' ;
487491}
488492
489493function trySelfParentPath ( parent ) {
490- if ( ! parent ) return false ;
494+ if ( ! parent ) { return false ; }
491495
492496if ( parent . filename ) {
493497return parent . filename ;
@@ -501,7 +505,7 @@ function trySelfParentPath(parent) {
501505}
502506
503507function trySelf ( parentPath , request ) {
504- if ( ! parentPath ) return false ;
508+ if ( ! parentPath ) { return false ; }
505509
506510const { data : pkg , path : pkgPath } = readPackageScope ( parentPath ) ;
507511if ( ! pkg || pkg . exports == null || pkg . name === undefined ) {
@@ -523,8 +527,9 @@ function trySelf(parentPath, request) {
523527pathToFileURL ( pkgPath + '/package.json' ) , expansion , pkg ,
524528pathToFileURL ( parentPath ) , getCjsConditions ( ) ) , parentPath , pkgPath ) ;
525529} catch ( e ) {
526- if ( e . code === 'ERR_MODULE_NOT_FOUND' )
530+ if ( e . code === 'ERR_MODULE_NOT_FOUND' ) {
527531throw createEsmNotFoundErr ( request , pkgPath + '/package.json' ) ;
532+ }
528533throw e ;
529534}
530535}
@@ -537,8 +542,7 @@ function resolveExports(nmPath, request) {
537542// The implementation's behavior is meant to mirror resolution in ESM.
538543const { 1 : name , 2 : expansion = '' } =
539544RegExpPrototypeExec ( EXPORTS_PATTERN , request ) || kEmptyObject ;
540- if ( ! name )
541- return ;
545+ if ( ! name ) { return ; }
542546const pkgPath = path . resolve ( nmPath , name ) ;
543547const pkg = _readPackage ( pkgPath ) ;
544548if ( pkg . exists && pkg . exports != null ) {
@@ -548,8 +552,9 @@ function resolveExports(nmPath, request) {
548552pathToFileURL ( pkgPath + '/package.json' ) , '.' + expansion , pkg , null ,
549553getCjsConditions ( ) ) , null , pkgPath ) ;
550554} catch ( e ) {
551- if ( e . code === 'ERR_MODULE_NOT_FOUND' )
555+ if ( e . code === 'ERR_MODULE_NOT_FOUND' ) {
552556throw createEsmNotFoundErr ( request , pkgPath + '/package.json' ) ;
557+ }
553558throw e ;
554559}
555560}
@@ -571,8 +576,9 @@ Module._findPath = function(request, paths, isMain) {
571576
572577const cacheKey = request + '\x00' + ArrayPrototypeJoin ( paths , '\x00' ) ;
573578const entry = Module . _pathCache [ cacheKey ] ;
574- if ( entry )
579+ if ( entry ) {
575580return entry ;
581+ }
576582
577583let exts ;
578584const trailingSlash = request . length > 0 &&
@@ -619,8 +625,9 @@ Module._findPath = function(request, paths, isMain) {
619625
620626if ( ! absoluteRequest ) {
621627const exportsResolved = resolveExports ( curPath , request ) ;
622- if ( exportsResolved )
628+ if ( exportsResolved ) {
623629return exportsResolved ;
630+ }
624631}
625632
626633const basePath = path . resolve ( curPath , request ) ;
@@ -652,16 +659,18 @@ Module._findPath = function(request, paths, isMain) {
652659
653660if ( ! filename ) {
654661// Try it with each of the extensions
655- if ( exts === undefined )
662+ if ( exts === undefined ) {
656663exts = ObjectKeys ( Module . _extensions ) ;
664+ }
657665filename = tryExtensions ( basePath , exts , isMain ) ;
658666}
659667}
660668
661669if ( ! filename && rc === 1 ) { // Directory.
662670// try it with each of the extensions at "index"
663- if ( exts === undefined )
671+ if ( exts === undefined ) {
664672exts = ObjectKeys ( Module . _extensions ) ;
673+ }
665674filename = tryPackage ( basePath , exts , isMain , request ) ;
666675}
667676
@@ -697,8 +706,9 @@ if (isWindows) {
697706// path.resolve will make sure from.length >=3 in Windows.
698707if ( StringPrototypeCharCodeAt ( from , from . length - 1 ) ===
699708CHAR_BACKWARD_SLASH &&
700- StringPrototypeCharCodeAt ( from , from . length - 2 ) === CHAR_COLON )
709+ StringPrototypeCharCodeAt ( from , from . length - 2 ) === CHAR_COLON ) {
701710return [ from + 'node_modules' ] ;
711+ }
702712
703713const paths = [ ] ;
704714for ( let i = from . length - 1 , p = 0 , last = from . length ; i >= 0 ; -- i ) {
@@ -711,11 +721,12 @@ if (isWindows) {
711721if ( code === CHAR_BACKWARD_SLASH ||
712722code === CHAR_FORWARD_SLASH ||
713723code === CHAR_COLON ) {
714- if ( p !== nmLen )
724+ if ( p !== nmLen ) {
715725ArrayPrototypePush (
716726paths ,
717727StringPrototypeSlice ( from , 0 , last ) + '\\node_modules' ,
718728) ;
729+ }
719730last = i ;
720731p = 0 ;
721732} else if ( p !== - 1 ) {
@@ -736,8 +747,9 @@ if (isWindows) {
736747from = path . resolve ( from ) ;
737748// Return early not only to avoid unnecessary work, but to *avoid* returning
738749// an array of two items for a root: [ '//node_modules', '/node_modules' ]
739- if ( from === '/' )
750+ if ( from === '/' ) {
740751return [ '/node_modules' ] ;
752+ }
741753
742754// note: this approach *only* works when the path is guaranteed
743755// to be absolute. Doing a fully-edge-case-correct path.split
@@ -746,11 +758,12 @@ if (isWindows) {
746758for ( let i = from . length - 1 , p = 0 , last = from . length ; i >= 0 ; -- i ) {
747759const code = StringPrototypeCharCodeAt ( from , i ) ;
748760if ( code === CHAR_FORWARD_SLASH ) {
749- if ( p !== nmLen )
761+ if ( p !== nmLen ) {
750762ArrayPrototypePush (
751763paths ,
752764StringPrototypeSlice ( from , 0 , last ) + '/node_modules' ,
753765) ;
766+ }
754767last = i ;
755768p = 0 ;
756769} else if ( p !== - 1 ) {
@@ -827,14 +840,15 @@ const CircularRequirePrototypeWarningProxy = new Proxy({}, {
827840// Allow __esModule access in any case because it is used in the output
828841// of transpiled code to determine whether something comes from an
829842// 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 ] ; }
831844emitCircularRequireWarning ( prop ) ;
832845return undefined ;
833846} ,
834847
835848getOwnPropertyDescriptor ( target , prop ) {
836- if ( ObjectPrototypeHasOwnProperty ( target , prop ) || prop === '__esModule' )
849+ if ( ObjectPrototypeHasOwnProperty ( target , prop ) || prop === '__esModule' ) {
837850return ObjectGetOwnPropertyDescriptor ( target , prop ) ;
851+ }
838852emitCircularRequireWarning ( prop ) ;
839853return undefined ;
840854} ,
@@ -878,8 +892,9 @@ Module._load = function(request, parent, isMain) {
878892const cachedModule = Module . _cache [ filename ] ;
879893if ( cachedModule !== undefined ) {
880894updateChildren ( parent , cachedModule , true ) ;
881- if ( ! cachedModule . loaded )
895+ if ( ! cachedModule . loaded ) {
882896return getExportsForCircularRequire ( cachedModule ) ;
897+ }
883898return cachedModule . exports ;
884899}
885900delete relativeResolveCache [ relResolveCacheIdentifier ] ;
@@ -904,8 +919,9 @@ Module._load = function(request, parent, isMain) {
904919updateChildren ( parent , cachedModule , true ) ;
905920if ( ! cachedModule . loaded ) {
906921const parseCachedModule = cjsParseCache . get ( cachedModule ) ;
907- if ( ! parseCachedModule || parseCachedModule . loaded )
922+ if ( ! parseCachedModule || parseCachedModule . loaded ) {
908923return getExportsForCircularRequire ( cachedModule ) ;
924+ }
909925parseCachedModule . loaded = true ;
910926} else {
911927return cachedModule . exports ;
@@ -988,8 +1004,9 @@ Module._resolveFilename = function(request, parent, isMain, options) {
9881004const lookupPaths = Module . _resolveLookupPaths ( request , fakeParent ) ;
9891005
9901006for ( let j = 0 ; j < lookupPaths . length ; j ++ ) {
991- if ( ! ArrayPrototypeIncludes ( paths , lookupPaths [ j ] ) )
1007+ if ( ! ArrayPrototypeIncludes ( paths , lookupPaths [ j ] ) ) {
9921008ArrayPrototypePush ( paths , lookupPaths [ j ] ) ;
1009+ }
9931010}
9941011}
9951012}
@@ -1013,8 +1030,9 @@ Module._resolveFilename = function(request, parent, isMain, options) {
10131030getCjsConditions ( ) ) , parentPath ,
10141031pkg . path ) ;
10151032} catch ( e ) {
1016- if ( e . code === 'ERR_MODULE_NOT_FOUND' )
1033+ if ( e . code === 'ERR_MODULE_NOT_FOUND' ) {
10171034throw createEsmNotFoundErr ( request ) ;
1035+ }
10181036throw e ;
10191037}
10201038}
@@ -1032,7 +1050,7 @@ Module._resolveFilename = function(request, parent, isMain, options) {
10321050
10331051// Look up the filename first, since that's the cache key.
10341052const filename = Module . _findPath ( request , paths , isMain ) ;
1035- if ( filename ) return filename ;
1053+ if ( filename ) { return filename ; }
10361054const requireStack = [ ] ;
10371055for ( let cursor = parent ;
10381056cursor ;
@@ -1053,13 +1071,15 @@ Module._resolveFilename = function(request, parent, isMain, options) {
10531071
10541072function finalizeEsmResolution ( resolved , parentPath , pkgPath ) {
10551073const { encodedSepRegEx } = require ( 'internal/modules/esm/resolve' ) ;
1056- if ( RegExpPrototypeExec ( encodedSepRegEx , resolved ) !== null )
1074+ if ( RegExpPrototypeExec ( encodedSepRegEx , resolved ) !== null ) {
10571075throw new ERR_INVALID_MODULE_SPECIFIER (
10581076resolved , 'must not include encoded "/" or "\\" characters' , parentPath ) ;
1077+ }
10591078const filename = fileURLToPath ( resolved ) ;
10601079const actual = tryFile ( filename ) ;
1061- if ( actual )
1080+ if ( actual ) {
10621081return actual ;
1082+ }
10631083const err = createEsmNotFoundErr ( filename ,
10641084path . resolve ( pkgPath , 'package.json' ) ) ;
10651085throw err ;
@@ -1069,8 +1089,9 @@ function createEsmNotFoundErr(request, path) {
10691089// eslint-disable-next-line no-restricted-syntax
10701090const err = new Error ( `Cannot find module '${ request } '` ) ;
10711091err . code = 'MODULE_NOT_FOUND' ;
1072- if ( path )
1092+ if ( path ) {
10731093err . path = path ;
1094+ }
10741095// TODO(BridgeAR): Add the requireStack as well.
10751096return err ;
10761097}
@@ -1085,8 +1106,9 @@ Module.prototype.load = function(filename) {
10851106
10861107const extension = findLongestRegisteredExtension ( filename ) ;
10871108// allow .mjs to be overridden
1088- if ( StringPrototypeEndsWith ( filename , '.mjs' ) && ! Module . _extensions [ '.mjs' ] )
1109+ if ( StringPrototypeEndsWith ( filename , '.mjs' ) && ! Module . _extensions [ '.mjs' ] ) {
10891110throw new ERR_REQUIRE_ESM ( filename , true ) ;
1111+ }
10901112
10911113Module . _extensions [ extension ] ( this , filename ) ;
10921114this . loaded = true ;
@@ -1097,8 +1119,9 @@ Module.prototype.load = function(filename) {
10971119// Preemptively cache
10981120if ( ( module ?. module === undefined ||
10991121module . module . getStatus ( ) < kEvaluated ) &&
1100- ! cascadedLoader . cjsCache . has ( this ) )
1122+ ! cascadedLoader . cjsCache . has ( this ) ) {
11011123cascadedLoader . cjsCache . set ( this , exports ) ;
1124+ }
11021125} ;
11031126
11041127// Loads a module at the given file path. Returns that module's
@@ -1233,7 +1256,7 @@ Module.prototype._compile = function(content, filename) {
12331256const exports = this . exports ;
12341257const thisValue = exports ;
12351258const module = this ;
1236- if ( requireDepth === 0 ) statCache = new SafeMap ( ) ;
1259+ if ( requireDepth === 0 ) { statCache = new SafeMap ( ) ; }
12371260if ( inspectorWrapper ) {
12381261result = inspectorWrapper ( compiledWrapper , thisValue , exports ,
12391262require , module , filename , dirname ) ;
@@ -1242,7 +1265,7 @@ Module.prototype._compile = function(content, filename) {
12421265[ exports , require , module , filename , dirname ] ) ;
12431266}
12441267hasLoadedAnyUserCJSModule = true ;
1245- if ( requireDepth === 0 ) statCache = null ;
1268+ if ( requireDepth === 0 ) { statCache = null ; }
12461269return result ;
12471270} ;
12481271
@@ -1399,8 +1422,7 @@ Module._initPaths = function() {
13991422} ;
14001423
14011424Module . _preloadModules = function ( requests ) {
1402- if ( ! ArrayIsArray ( requests ) )
1403- return ;
1425+ if ( ! ArrayIsArray ( requests ) ) { return ; }
14041426
14051427isPreloading = true ;
14061428
@@ -1416,8 +1438,9 @@ Module._preloadModules = function(requests) {
14161438throw e ;
14171439}
14181440}
1419- for ( let n = 0 ; n < requests . length ; n ++ )
1441+ for ( let n = 0 ; n < requests . length ; n ++ ) {
14201442internalRequire ( parent , requests [ n ] ) ;
1443+ }
14211444isPreloading = false ;
14221445} ;
14231446
0 commit comments