File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -196,9 +196,16 @@ namespace ts {
196196 if ( platform === "win32" || platform === "win64" ) {
197197 return false ;
198198 }
199- // convert current file name to upper case / lower case and check if file exists
200- // (guards against cases when name is already all uppercase or lowercase)
201- return ! fileExists ( __filename . toUpperCase ( ) ) || ! fileExists ( __filename . toLowerCase ( ) ) ;
199+ // If this file exists under a different case, we must be case-insensitve.
200+ return ! fileExists ( swapCase ( __filename ) ) ;
201+ }
202+
203+ /** Convert all lowercase chars to uppercase, and vice-versa */
204+ function swapCase ( s : string ) : string {
205+ return s . replace ( / \w / g, ( ch ) => {
206+ const up = ch . toUpperCase ( ) ;
207+ return ch === up ? ch . toLowerCase ( ) : up ;
208+ } ) ;
202209 }
203210
204211 const platform : string = _os . platform ( ) ;
You can’t perform that action at this time.
0 commit comments