File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -21,8 +21,6 @@ const reservedPatterns = args[1]
21
21
? args [ 1 ] . split ( '|' ) . map ( part => new RegExp ( part ) )
22
22
: [ ] ;
23
23
24
- let tsconfig = { } ;
25
-
26
24
function help ( ) {
27
25
console . error ( 'usage: ' ) ;
28
26
console . error (
@@ -36,8 +34,15 @@ if (!src.length) {
36
34
process . exit ( 1 ) ;
37
35
}
38
36
39
- if ( fs . existsSync ( 'tsconfig.json' ) ) {
40
- tsconfig = ts . getParsedCommandLineOfConfigFile ( 'tsconfig.json' , { esModuleInterop : true } , ts . sys ) ;
37
+ function getTsConfigCompilerOptions ( ) {
38
+ // Since extract-meta can be run on JavaScript sources, if trying to get the
39
+ // config doesn't work, we can fall back gracefully.
40
+ try {
41
+ const tsconfig = ts . getParsedCommandLineOfConfigFile ( 'tsconfig.json' , { esModuleInterop : true } , ts . sys ) ;
42
+ return tsconfig ?. options ?? { } ;
43
+ } catch {
44
+ return { } ;
45
+ }
41
46
}
42
47
43
48
let failedBuild = false ;
@@ -187,7 +192,7 @@ function gatherComponents(sources, components = {}) {
187
192
return components ;
188
193
}
189
194
190
- const program = ts . createProgram ( filepaths , tsconfig ) ;
195
+ const program = ts . createProgram ( filepaths , getTsConfigCompilerOptions ( ) ) ;
191
196
const checker = program . getTypeChecker ( ) ;
192
197
193
198
const coerceValue = t => {
You can’t perform that action at this time.
0 commit comments