From 9e2ec7a1aa9f8d46d9286a992d80c14112cb7d4d Mon Sep 17 00:00:00 2001 From: Alex Eagle Date: Wed, 7 Sep 2016 16:24:52 -0700 Subject: [PATCH] fix(ngc): use the compilerHost to detect file existence (#11418) --- modules/@angular/compiler-cli/src/reflector_host.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/@angular/compiler-cli/src/reflector_host.ts b/modules/@angular/compiler-cli/src/reflector_host.ts index 0b97f3700a..3ef91c173b 100644 --- a/modules/@angular/compiler-cli/src/reflector_host.ts +++ b/modules/@angular/compiler-cli/src/reflector_host.ts @@ -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 {