fix(ngc): use the compilerHost to detect file existence (#11418)

This commit is contained in:
Alex Eagle 2016-09-07 16:24:52 -07:00 committed by Evan Martin
parent 643afa4b15
commit 9e2ec7a1aa
1 changed files with 4 additions and 2 deletions

View File

@ -39,7 +39,7 @@ export class ReflectorHost implements StaticReflectorHost, ImportGenerator {
this.basePath = path.normalize(path.join(this.options.basePath, '.')).replace(/\\/g, '/');
this.genDir = path.normalize(path.join(this.options.genDir, '.')).replace(/\\/g, '/');
this.context = context || new NodeReflectorHostContext();
this.context = context || new NodeReflectorHostContext(compilerHost);
var genPath: string = path.relative(this.basePath, this.genDir);
this.isGenDirChildOfRootDir = genPath === '' || !genPath.startsWith('..');
}
@ -326,10 +326,12 @@ export class ReflectorHost implements StaticReflectorHost, ImportGenerator {
}
export class NodeReflectorHostContext implements ReflectorHostContext {
constructor(private host: ts.CompilerHost) {}
private assumedExists: {[fileName: string]: boolean} = {};
fileExists(fileName: string): boolean {
return this.assumedExists[fileName] || fs.existsSync(fileName);
return this.assumedExists[fileName] || this.host.fileExists(fileName);
}
directoryExists(directoryName: string): boolean {