From 85d589431c5469117a1f0caece44c48bbdefcf38 Mon Sep 17 00:00:00 2001 From: Torben Fitschen Date: Fri, 9 Sep 2016 11:07:23 +0200 Subject: [PATCH 1/2] Added detection for case sensitive file systems --- src/compiler/sys.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index 437cf8e05ec06..171f44391030f 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -311,9 +311,19 @@ namespace ts { return parseInt(process.version.charAt(1)) >= 4; } + function isFileSystemCaseSensitive(): boolean { + // win32\win64 are case insensitive platforms + if (platform === "win32" || platform === "win64") { + return false; + } + + const upperCaseFilename = _path.basename(__filename).toUpperCase(); + + return !fileExists(_path.join(_path.dirname(__filename), upperCaseFilename)); + } + const platform: string = _os.platform(); - // win32\win64 are case insensitive platforms, MacOS (darwin) by default is also case insensitive - const useCaseSensitiveFileNames = platform !== "win32" && platform !== "win64" && platform !== "darwin"; + const useCaseSensitiveFileNames = isFileSystemCaseSensitive(); function readFile(fileName: string, encoding?: string): string { if (!fileExists(fileName)) { From 5cdbe773c6a89075cceb966474b6d6dba6869cf8 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Mon, 3 Oct 2016 14:42:06 -0700 Subject: [PATCH 2/2] guard against cases when current file name is already in uppercase --- src/compiler/sys.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index ed89b9d161138..2d4fcd241aa04 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -316,10 +316,9 @@ namespace ts { if (platform === "win32" || platform === "win64") { return false; } - - const upperCaseFilename = _path.basename(__filename).toUpperCase(); - - return !fileExists(_path.join(_path.dirname(__filename), upperCaseFilename)); + // convert current file name to upper case / lower case and check if file exists + // (guards against cases when name is already all uppercase or lowercase) + return !fileExists(__filename.toUpperCase()) || !fileExists(__filename.toLowerCase()); } const platform: string = _os.platform();