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