@@ -117,23 +117,22 @@ export class CodeFileLoader implements Loader<CodeFileLoaderOptions> {
117117 return globby . sync ( [ glob , ...ignores . map ( v => `!${ v } ` ) . map ( v => unixify ( v ) ) ] , createGlobbyOptions ( options ) ) ;
118118 }
119119
120- async load ( pointer : string , options : CodeFileLoaderOptions ) : Promise < Source [ ] | null > {
120+ async load ( pointer : string , options : CodeFileLoaderOptions ) : Promise < Source [ ] > {
121121 options = this . getMergedOptions ( options ) ;
122+ const finalResult : Source [ ] = [ ] ;
123+
122124 if ( isGlob ( pointer ) ) {
123125 const resolvedPaths = await this . resolveGlobs ( pointer , options ) ;
124- const finalResult : Source [ ] = [ ] ;
125126 await Promise . all (
126127 resolvedPaths . map ( async path => {
127- if ( await this . canLoad ( path , options ) ) {
128- const result = await this . handleSinglePath ( path , options ) ;
129- result ?. forEach ( result => finalResult . push ( result ) ) ;
130- }
128+ finalResult . push ( ...( await this . handleSinglePath ( path , options ) ) ) ;
131129 } )
132130 ) ;
133- return finalResult ;
131+ } else {
132+ finalResult . push ( ...( await this . handleSinglePath ( pointer , options ) ) ) ;
134133 }
135134
136- return this . handleSinglePath ( pointer , options ) ;
135+ return finalResult ;
137136 }
138137
139138 loadSync ( pointer : string , options : CodeFileLoaderOptions ) : Source [ ] | null {
@@ -153,7 +152,11 @@ export class CodeFileLoader implements Loader<CodeFileLoaderOptions> {
153152 return this . handleSinglePathSync ( pointer , options ) ;
154153 }
155154
156- async handleSinglePath ( location : string , options : CodeFileLoaderOptions ) : Promise < Source [ ] | null > {
155+ async handleSinglePath ( location : string , options : CodeFileLoaderOptions ) : Promise < Source [ ] > {
156+ if ( ! ( await this . canLoad ( location , options ) ) ) {
157+ return [ ] ;
158+ }
159+
157160 options = this . getMergedOptions ( options ) ;
158161 const normalizedFilePath = ensureAbsolutePath ( location , options ) ;
159162
@@ -200,10 +203,13 @@ export class CodeFileLoader implements Loader<CodeFileLoaderOptions> {
200203 throw errors [ 0 ] ;
201204 }
202205
203- return null ;
206+ return [ ] ;
204207 }
205208
206209 handleSinglePathSync ( location : string , options : CodeFileLoaderOptions ) : Source [ ] | null {
210+ if ( ! this . canLoadSync ( location , options ) ) {
211+ return [ ] ;
212+ }
207213 options = this . getMergedOptions ( options ) ;
208214 const normalizedFilePath = ensureAbsolutePath ( location , options ) ;
209215
0 commit comments