@@ -52,33 +52,25 @@ export class BaseBooter implements Booter {
5252 * NOTE: All properties are configured even if all aren't used.
5353 */
5454 async configure ( ) {
55- if ( this . options . dirs ) {
56- this . dirs = Array . isArray ( this . options . dirs )
57- ? this . options . dirs
58- : [ this . options . dirs ] ;
59- } else {
60- this . dirs = [ ] ;
61- }
55+ this . dirs = this . normalizeToArray ( this . options . dirs ) ;
56+ this . extensions = this . normalizeToArray ( this . options . extensions ) ;
6257
63- if ( this . options . extensions ) {
64- this . extensions = Array . isArray ( this . options . extensions )
65- ? this . options . extensions
66- : [ this . options . extensions ] ;
67- } else {
68- this . extensions = [ ] ;
69- }
58+ const joinedDirs = this . formatDirs ( this . dirs ) ;
59+ const joinedExts = `@(${ this . extensions . join ( '|' ) } )` ;
7060
71- let joinedDirs = this . dirs . join ( ',' ) ;
72- if ( this . dirs . length > 1 ) joinedDirs = `{${ joinedDirs } }` ;
61+ this . glob =
62+ this . options . glob ??
63+ `/${ joinedDirs } /${ this . options . nested ? '**/*' : '*' } ${ joinedExts } ` ;
64+ }
7365
74- const joinedExts = `@(${ this . extensions . join ( '|' ) } )` ;
66+ private normalizeToArray < T > ( value : T | T [ ] | undefined ) : T [ ] {
67+ if ( ! value ) return [ ] ;
68+ return Array . isArray ( value ) ? value : [ value ] ;
69+ }
7570
76- if ( this . options . glob ) {
77- this . glob = this . options . glob ;
78- } else {
79- const pattern = this . options . nested ? '**/*' : '*' ;
80- this . glob = `/${ joinedDirs } /${ pattern } ${ joinedExts } ` ;
81- }
71+ private formatDirs ( dirs : string [ ] ) : string {
72+ if ( dirs . length > 1 ) return `{${ dirs . join ( ',' ) } }` ;
73+ return dirs . join ( ',' ) ;
8274 }
8375
8476 /**
0 commit comments