diff --git a/packages/compiler-cli/src/ngtsc/file_system/src/node_js_file_system.ts b/packages/compiler-cli/src/ngtsc/file_system/src/node_js_file_system.ts index 2a1a41a7b5d24..9e50a8e4945ef 100644 --- a/packages/compiler-cli/src/ngtsc/file_system/src/node_js_file_system.ts +++ b/packages/compiler-cli/src/ngtsc/file_system/src/node_js_file_system.ts @@ -68,7 +68,9 @@ export class NodeJSFileSystem implements FileSystem { } isCaseSensitive(): boolean { if (this._caseSensitive === undefined) { - this._caseSensitive = this.exists(togglePathCase(__filename)); + // Note the use of the real file-system is intentional: + // `this.exists()` relies upon `isCaseSensitive()` so that would cause an infinite recursion. + this._caseSensitive = !fs.existsSync(togglePathCase(__filename)); } return this._caseSensitive; } diff --git a/packages/compiler-cli/src/ngtsc/file_system/test/node_js_file_system_spec.ts b/packages/compiler-cli/src/ngtsc/file_system/test/node_js_file_system_spec.ts index eca3261239d1c..2e15f6b64663f 100644 --- a/packages/compiler-cli/src/ngtsc/file_system/test/node_js_file_system_spec.ts +++ b/packages/compiler-cli/src/ngtsc/file_system/test/node_js_file_system_spec.ts @@ -153,14 +153,6 @@ describe('NodeJSFileSystem', () => { expect(mkdirCalls).toEqual([xPath, xyPath, xyzPath]); }); - describe('removeDeep()', () => { - it('should delegate to fsExtra.remove()', () => { - const spy = spyOn(fsExtra, 'removeSync'); - fs.removeDeep(abcPath); - expect(spy).toHaveBeenCalledWith(abcPath); - }); - }); - it('should not fail if a directory (that did not exist before) does exist when trying to create it', () => { let abcPathExists = false; @@ -228,4 +220,19 @@ describe('NodeJSFileSystem', () => { expect(isDirectorySpy).toHaveBeenCalledTimes(1); }); }); + + describe('removeDeep()', () => { + it('should delegate to fsExtra.remove()', () => { + const spy = spyOn(fsExtra, 'removeSync'); + fs.removeDeep(abcPath); + expect(spy).toHaveBeenCalledWith(abcPath); + }); + }); + + describe('isCaseSensitive()', () => { + it('should return true if the FS is case-sensitive', () => { + const isCaseSensitive = !realFs.existsSync(__filename.toUpperCase()); + expect(fs.isCaseSensitive()).toEqual(isCaseSensitive); + }); + }); });