fix(ngc): use the compilerHost to detect file existence (#11418)
This commit is contained in:
parent
643afa4b15
commit
9e2ec7a1aa
|
@ -39,7 +39,7 @@ export class ReflectorHost implements StaticReflectorHost, ImportGenerator {
|
||||||
this.basePath = path.normalize(path.join(this.options.basePath, '.')).replace(/\\/g, '/');
|
this.basePath = path.normalize(path.join(this.options.basePath, '.')).replace(/\\/g, '/');
|
||||||
this.genDir = path.normalize(path.join(this.options.genDir, '.')).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);
|
var genPath: string = path.relative(this.basePath, this.genDir);
|
||||||
this.isGenDirChildOfRootDir = genPath === '' || !genPath.startsWith('..');
|
this.isGenDirChildOfRootDir = genPath === '' || !genPath.startsWith('..');
|
||||||
}
|
}
|
||||||
|
@ -326,10 +326,12 @@ export class ReflectorHost implements StaticReflectorHost, ImportGenerator {
|
||||||
}
|
}
|
||||||
|
|
||||||
export class NodeReflectorHostContext implements ReflectorHostContext {
|
export class NodeReflectorHostContext implements ReflectorHostContext {
|
||||||
|
constructor(private host: ts.CompilerHost) {}
|
||||||
|
|
||||||
private assumedExists: {[fileName: string]: boolean} = {};
|
private assumedExists: {[fileName: string]: boolean} = {};
|
||||||
|
|
||||||
fileExists(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 {
|
directoryExists(directoryName: string): boolean {
|
||||||
|
|
Loading…
Reference in New Issue