File tree 1 file changed +27
-6
lines changed
1 file changed +27
-6
lines changed Original file line number Diff line number Diff line change @@ -161,19 +161,40 @@ export const loadConfig = (file: string, output: IOutput): ITSConfig => {
161
161
output . debug ( 'loaded config (from file):' , config ) ;
162
162
if ( ext ) {
163
163
return {
164
- ...( ext . startsWith ( '.' )
165
- ? loadConfig (
166
- join ( configDir , ext . endsWith ( '.json' ) ? ext : `${ ext } .json` ) ,
167
- output
168
- )
169
- : loadConfig ( resolveTsConfigExtendsPath ( ext , file ) , output ) ) ,
164
+ ...normalizeTsConfigExtendsOption ( ext , file ) . reduce < ITSConfig > (
165
+ ( pre , ext ) => ( {
166
+ ...pre ,
167
+ ...loadConfig ( ext , output )
168
+ } ) ,
169
+ { }
170
+ ) ,
170
171
...config
171
172
} ;
172
173
}
173
174
174
175
return config ;
175
176
} ;
176
177
178
+ /**
179
+ * normalizeTsConfigExtendsOption normalizes tsconfig extends option to a directly loadable path array
180
+ * @param { string|string[] } ext
181
+ * @param { string } file
182
+ * @returns {string[] }
183
+ */
184
+ export function normalizeTsConfigExtendsOption (
185
+ ext : string | string [ ] ,
186
+ file : string
187
+ ) : string [ ] {
188
+ if ( ! ext ) return [ ] ;
189
+ const configDir = dirname ( file ) ;
190
+ const normExts = ( Array . isArray ( ext ) ? ext : [ ext ] ) . map ( ( e ) =>
191
+ e . startsWith ( '.' )
192
+ ? join ( configDir , e . endsWith ( '.json' ) ? e : `${ e } .json` )
193
+ : resolveTsConfigExtendsPath ( e , file )
194
+ ) ;
195
+ return normExts ;
196
+ }
197
+
177
198
/**
178
199
* resolveTsConfigExtendsPath resolves the path to the config file that is being inherited.
179
200
* @param {string } ext the value of the extends field in the loaded config file.
You can’t perform that action at this time.
0 commit comments