Skip to content

Commit

Permalink
fix(compiler-cli): isCaseSensitive() returns correct value (#36968)
Browse files Browse the repository at this point in the history
Previously this method was returning the exact opposite value
than the correct one.
Also, calling `this.exists()` causes an infinite recursions,
so the actual file-system `fs.existsSync()` method is used
to ascertain the case-sensitivity of the file-system.

PR Close #36968
  • Loading branch information
petebacondarwin authored and alxhub committed May 7, 2020
1 parent 5bddeea commit 4becc1b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
Expand Up @@ -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;
}
Expand Down
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
});
});
});

0 comments on commit 4becc1b

Please sign in to comment.