Skip to content

Commit

Permalink
fix(compiler-cli): fix case-sensitivity issues in NgtscCompilerHost (#…
Browse files Browse the repository at this point in the history
…36968)

The `getCanonicalFileName()` method was not actually
calling the  `useCaseSensitiveFileNames()` method. So
it always returned a case-sensitive canonical filename.

PR Close #36968
  • Loading branch information
petebacondarwin authored and alxhub committed May 7, 2020
1 parent 9d13ee0 commit 4abd603
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
Expand Up @@ -44,7 +44,7 @@ export class NgtscCompilerHost implements ts.CompilerHost {
}

getCanonicalFileName(fileName: string): string {
return this.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase();
return this.useCaseSensitiveFileNames() ? fileName : fileName.toLowerCase();
}

useCaseSensitiveFileNames(): boolean {
Expand Down
Expand Up @@ -41,5 +41,27 @@ runInEachFileSystem(() => {
expect(host.getSourceFile(directory, ts.ScriptTarget.ES2015)).toBe(undefined);
});
});

describe('useCaseSensitiveFileNames()', () => {
it('should return the same as `FileSystem.isCaseSensitive()', () => {
const directory = absoluteFrom('/a/b/c');
const fs = getFileSystem();
fs.ensureDir(directory);
const host = new NgtscCompilerHost(fs);
expect(host.useCaseSensitiveFileNames()).toEqual(fs.isCaseSensitive());
});
});

describe('getCanonicalFileName()', () => {
it('should return the original filename if FS is case-sensitive or lower case otherwise',
() => {
const directory = absoluteFrom('/a/b/c');
const fs = getFileSystem();
fs.ensureDir(directory);
const host = new NgtscCompilerHost(fs);
expect(host.getCanonicalFileName(('AbCd.ts')))
.toEqual(fs.isCaseSensitive() ? 'AbCd.ts' : 'abcd.ts');
});
});
});
});

0 comments on commit 4abd603

Please sign in to comment.