@@ -601,77 +601,75 @@ function writeJavascriptIndexFiles() {
601
601
// Regexp's
602
602
const RE_AUTOGEN_EXT = / \. a u t o g e n \. j s $ / ;
603
603
604
- function writeIndexForDir ( dirPath , isTopLevel ) {
604
+ async function writeIndexForDir ( dirPath , isTopLevel ) {
605
605
606
606
const dirAbsPath = path . resolve ( jsSrcDir , dirPath ) ;
607
607
608
608
// Generate list of files in dir to include in index.js as require lines
609
- return fse . readdir ( dirAbsPath ) . then ( function ( dirFiles ) {
609
+ let dirFiles = await fse . readdir ( dirAbsPath ) ;
610
610
611
- // get proper relative path for file
612
- dirFiles = dirFiles . map ( function ( filename ) {
613
- return './' + path . join ( dirPath , filename ) ;
614
- } ) ;
611
+ // get proper relative path for file
612
+ dirFiles = dirFiles . map ( filename => {
613
+ return './' + path . join ( dirPath , filename ) ;
614
+ } ) ;
615
615
616
- // filter excluded files
617
- dirFiles = dirFiles . filter ( function ( filePath ) {
616
+ // filter excluded files
617
+ dirFiles = dirFiles . filter ( filePath => {
618
618
619
- // ignore autogen files in _base dir
620
- if ( / _ b a s e / . test ( dirPath ) && RE_AUTOGEN_EXT . test ( filePath ) ) {
621
- return false ;
622
- }
619
+ // ignore autogen files in _base dir
620
+ if ( / _ b a s e / . test ( dirPath ) && RE_AUTOGEN_EXT . test ( filePath ) ) {
621
+ return false ;
622
+ }
623
623
624
- // compare filePath to each exclude pattern
625
- const shouldExclude = _ . any ( excludes , function ( testPattern ) {
626
- if ( testPattern instanceof RegExp ) {
627
- return testPattern . test ( filePath ) ;
628
- } else if ( typeof testPattern === 'string' ) {
629
- return testPattern === filePath ;
630
- }
631
- } ) ;
632
- if ( shouldExclude ) {
633
- return false ;
624
+ // compare filePath to each exclude pattern
625
+ const shouldExclude = _ . any ( excludes , function ( testPattern ) {
626
+ if ( testPattern instanceof RegExp ) {
627
+ return testPattern . test ( filePath ) ;
628
+ } else if ( typeof testPattern === 'string' ) {
629
+ return testPattern === filePath ;
634
630
}
631
+ } ) ;
632
+ if ( shouldExclude ) {
633
+ return false ;
634
+ }
635
635
636
- // if override class exists, load it in favor of the autogen file
637
- // e.g. for WebGLRenderer.js, Object3D.js, DataTexture.js
638
- // override classes should extend the autogen versions
639
- if ( RE_AUTOGEN_EXT . test ( filePath ) ) {
640
-
641
- const dirname = path . dirname ( filePath ) ;
642
- const basename = path . basename ( filePath , JS_AUTOGEN_EXT ) ;
643
- const overrideName = basename + '.js' ;
644
- const overridePath = './' + path . join ( dirname , overrideName ) ;
636
+ // if override class exists, load it in favor of the autogen file
637
+ // e.g. for WebGLRenderer.js, Object3D.js, DataTexture.js
638
+ // override classes should extend the autogen versions
639
+ if ( RE_AUTOGEN_EXT . test ( filePath ) ) {
645
640
646
- // override file present, so don't include autogen file in index
647
- if ( dirFiles . indexOf ( overridePath ) > - 1 ) {
648
- console . log ( 'override exists for: ' + filePath ) ;
649
- return false ;
650
- }
641
+ const dirname = path . dirname ( filePath ) ;
642
+ const basename = path . basename ( filePath , JS_AUTOGEN_EXT ) ;
643
+ const overrideName = basename + '.js' ;
644
+ const overridePath = './' + path . join ( dirname , overrideName ) ;
651
645
646
+ // override file present, so don't include autogen file in index
647
+ if ( dirFiles . indexOf ( overridePath ) > - 1 ) {
648
+ console . log ( 'override exists for: ' + filePath ) ;
649
+ return false ;
652
650
}
653
651
654
- return true ;
655
- } ) ;
652
+ }
656
653
657
- // convert file paths relative to js src dir to paths relative to dirPath
658
- dirFiles = dirFiles . map ( function ( filePath ) {
659
- return './' + path . basename ( filePath ) ;
660
- } ) ;
654
+ return true ;
655
+ } ) ;
661
656
662
- // render template
663
- const context = {
664
- now : new Date ( ) ,
665
- generatorScriptName : path . basename ( __filename ) ,
666
- top_level : isTopLevel ,
667
- submodules : dirFiles ,
668
- } ;
669
- const output = jsIndexTemplate ( context ) ;
670
- const outputPath = path . resolve ( jsSrcDir , dirPath , 'index.js' ) ;
657
+ // convert file paths relative to js src dir to paths relative to dirPath
658
+ dirFiles = dirFiles . map ( function ( filePath ) {
659
+ return './' + path . basename ( filePath ) ;
660
+ } ) ;
671
661
672
- return fse . outputFile ( outputPath , output ) ;
662
+ // render template
663
+ const context = {
664
+ now : new Date ( ) ,
665
+ generatorScriptName : path . basename ( __filename ) ,
666
+ top_level : isTopLevel ,
667
+ submodules : dirFiles ,
668
+ } ;
669
+ const output = jsIndexTemplate ( context ) ;
670
+ const outputPath = path . resolve ( jsSrcDir , dirPath , 'index.js' ) ;
673
671
674
- } ) ;
672
+ return fse . outputFile ( outputPath , output ) ;
675
673
}
676
674
677
675
// map over all directories in js src dir
0 commit comments