File tree 1 file changed +7
-0
lines changed
1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,9 @@ import * as ts from "typescript";
3
3
import * as fs from "fs" ;
4
4
import * as path from "path" ;
5
5
6
+ declare type CONFIG_CACHE < T > = { [ file : string ] : T } ;
7
+ const TSCONFIG_CACHE : CONFIG_CACHE < ts . ParsedCommandLine > = { } ;
8
+
6
9
export function createDefaultFormatCodeSettings ( ) : ts . FormatCodeSettings {
7
10
8
11
return {
@@ -49,6 +52,8 @@ export function readFilesFromTsconfig(configPath: string): string[] {
49
52
}
50
53
51
54
export function readTsconfig ( configPath : string ) : ts . ParsedCommandLine {
55
+ if ( TSCONFIG_CACHE [ configPath ] ) return TSCONFIG_CACHE [ configPath ] ;
56
+
52
57
// for `extends` support. It supported from TypeScript 2.1.1.
53
58
// `& { readFile(path: string): string; }` is backword compat for TypeScript compiler 2.0.3 support.
54
59
const host : ts . ParseConfigHost & { readFile ( path : string ) : string ; } = {
@@ -63,6 +68,8 @@ export function readTsconfig(configPath: string): ts.ParsedCommandLine {
63
68
throw new Error ( parsed . errors . map ( e => e . messageText ) . join ( "\n" ) ) ;
64
69
}
65
70
71
+ TSCONFIG_CACHE [ configPath ] = parsed ;
72
+
66
73
return parsed ;
67
74
}
68
75
You can’t perform that action at this time.
0 commit comments