Skip to content

Commit adeb2a2

Browse files
authored
Merge pull request microsoft#11332 from Microsoft/vladima/fs-case-sensitivity
check case sensitivity of host file system.
2 parents 4800464 + 5cdbe77 commit adeb2a2

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/compiler/sys.ts

+11-2
Original file line numberDiff line numberDiff line change
@@ -311,9 +311,18 @@ namespace ts {
311311
return parseInt(process.version.charAt(1)) >= 4;
312312
}
313313

314+
function isFileSystemCaseSensitive(): boolean {
315+
// win32\win64 are case insensitive platforms
316+
if (platform === "win32" || platform === "win64") {
317+
return false;
318+
}
319+
// convert current file name to upper case / lower case and check if file exists
320+
// (guards against cases when name is already all uppercase or lowercase)
321+
return !fileExists(__filename.toUpperCase()) || !fileExists(__filename.toLowerCase());
322+
}
323+
314324
const platform: string = _os.platform();
315-
// win32\win64 are case insensitive platforms, MacOS (darwin) by default is also case insensitive
316-
const useCaseSensitiveFileNames = platform !== "win32" && platform !== "win64" && platform !== "darwin";
325+
const useCaseSensitiveFileNames = isFileSystemCaseSensitive();
317326

318327
function readFile(fileName: string, encoding?: string): string {
319328
if (!fileExists(fileName)) {

0 commit comments

Comments
 (0)