Skip to content

Commit e48eb0d

Browse files
committed
Merge branch 'stweedie-master'
2 parents f6b8e23 + fb0ace7 commit e48eb0d

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

lib/utils.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import * as ts from "typescript";
33
import * as fs from "fs";
44
import * as path from "path";
55

6+
const TSCONFIG_CACHE: { [filePath: string]: ts.ParsedCommandLine; } = {};
7+
68
export function createDefaultFormatCodeSettings(): ts.FormatCodeSettings {
79

810
return {
@@ -49,6 +51,10 @@ export function readFilesFromTsconfig(configPath: string): string[] {
4951
}
5052

5153
export function readTsconfig(configPath: string): ts.ParsedCommandLine {
54+
if (TSCONFIG_CACHE[configPath]) {
55+
return TSCONFIG_CACHE[configPath];
56+
}
57+
5258
// for `extends` support. It supported from TypeScript 2.1.1.
5359
// `& { readFile(path: string): string; }` is backword compat for TypeScript compiler 2.0.3 support.
5460
const host: ts.ParseConfigHost & { readFile(path: string): string; } = {
@@ -63,6 +69,8 @@ export function readTsconfig(configPath: string): ts.ParsedCommandLine {
6369
throw new Error(parsed.errors.map(e => e.messageText).join("\n"));
6470
}
6571

72+
TSCONFIG_CACHE[configPath] = parsed;
73+
6674
return parsed;
6775
}
6876

0 commit comments

Comments
 (0)