build: fix failing compiler-cli tests on windows (#28550)

Note that this fixes `compiler-cli` tests within `compiler-cli/test`,
but there seem to be remaining `ngcc` tests within `compiler-cli/src`
which aren't working on Windows. This is out-of-scope for this commit.

PR Close #28550
This commit is contained in:
Paul Gschwendtner
2019-01-25 19:50:08 +01:00
committed by Matias Niemelä
parent 91ce8c17ff
commit c378402af4
5 changed files with 96 additions and 62 deletions

View File

@ -75,11 +75,11 @@ export class MockLanguageServiceHost implements ts.LanguageServiceHost {
private internalReadFile(fileName: string): string|undefined {
let basename = path.basename(fileName);
if (/^lib.*\.d\.ts$/.test(basename)) {
let libPath = path.dirname(ts.getDefaultLibFilePath(this.getCompilationSettings()));
fileName = path.join(libPath, basename);
let libPath = path.posix.dirname(ts.getDefaultLibFilePath(this.getCompilationSettings()));
fileName = path.posix.join(libPath, basename);
}
if (fileName.startsWith('app/')) {
fileName = path.join(this.context.currentDirectory, fileName);
fileName = path.posix.join(this.context.currentDirectory, fileName);
}
if (this.context.fileExists(fileName)) {
return this.context.readFile(fileName);