Skip to content
This repository was archived by the owner on May 1, 2020. It is now read-only.

Commit b766037

Browse files
committed
fix(aot): normalize paths to fix path issues on windows
1 parent 284fd3b commit b766037

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/aot/compiler-host.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { normalize } from 'path';
12
import { CancellationToken, CompilerHost, CompilerOptions, createCompilerHost, ScriptTarget, SourceFile } from 'typescript';
23
import { VirtualFileSystem } from '../util/interfaces';
34
import { getTypescriptSourceFile } from '../util/typescript-utils';
@@ -17,6 +18,7 @@ export class InMemoryCompilerHost implements CompilerHost {
1718
}
1819

1920
fileExists(filePath: string): boolean {
21+
filePath = normalize(filePath);
2022
const fileContent = this.fileSystem.getFileContent(filePath);
2123
if (fileContent) {
2224
return true;
@@ -25,6 +27,7 @@ export class InMemoryCompilerHost implements CompilerHost {
2527
}
2628

2729
readFile(filePath: string): string {
30+
filePath = normalize(filePath);
2831
const fileContent = this.fileSystem.getFileContent(filePath);
2932
if (fileContent) {
3033
return fileContent;
@@ -33,6 +36,7 @@ export class InMemoryCompilerHost implements CompilerHost {
3336
}
3437

3538
directoryExists(directoryPath: string): boolean {
39+
directoryPath = normalize(directoryPath);
3640
const stats = this.fileSystem.getDirectoryStats(directoryPath);
3741
if (stats) {
3842
return true;
@@ -41,10 +45,12 @@ export class InMemoryCompilerHost implements CompilerHost {
4145
}
4246

4347
getFiles(directoryPath: string): string[] {
48+
directoryPath = normalize(directoryPath);
4449
return this.fileSystem.getFileNamesInDirectory(directoryPath);
4550
}
4651

4752
getDirectories(directoryPath: string): string[] {
53+
directoryPath = normalize(directoryPath);
4854
const subdirs = this.fileSystem.getSubDirs(directoryPath);
4955

5056
let delegated: string[];
@@ -57,6 +63,7 @@ export class InMemoryCompilerHost implements CompilerHost {
5763
}
5864

5965
getSourceFile(filePath: string, languageVersion: ScriptTarget, onError?: OnErrorFn) {
66+
filePath = normalize(filePath);
6067
const existingSourceFile = this.sourceFileMap.get(filePath);
6168
if (existingSourceFile) {
6269
return existingSourceFile;
@@ -82,6 +89,7 @@ export class InMemoryCompilerHost implements CompilerHost {
8289
}
8390

8491
writeFile(fileName: string, data: string, writeByteOrderMark: boolean, onError?: OnErrorFn) {
92+
fileName = normalize(fileName);
8593
Logger.debug(`[NgcCompilerHost] writeFile: adding ${fileName} to virtual file system`);
8694
this.fileSystem.addVirtualFile(fileName, data);
8795
}

0 commit comments

Comments
 (0)