-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Add case sensitivity-check to computeCommonSourceDirectory #5590
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
6dcf3cf
97d170b
a1cf51f
ebd7d2d
5ea25ba
c3af8bb
dc466b2
b24f8f3
5bcf861
52fbf9e
ecd4435
c3c758b
ff95731
bfdb2d0
39ebe81
3fd9eb5
a989595
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -904,7 +904,7 @@ namespace ts { | |
|
|
||
| function computeCommonSourceDirectory(sourceFiles: SourceFile[]): string { | ||
| let commonPathComponents: string[]; | ||
| forEach(files, sourceFile => { | ||
| const failed = forEach(files, sourceFile => { | ||
| // Each file contributes into common source file path | ||
| if (isDeclarationFile(sourceFile)) { | ||
| return; | ||
|
|
@@ -920,10 +920,10 @@ namespace ts { | |
| } | ||
|
|
||
| for (let i = 0, n = Math.min(commonPathComponents.length, sourcePathComponents.length); i < n; i++) { | ||
| if (commonPathComponents[i] !== sourcePathComponents[i]) { | ||
| if (getCanonicalFileName(commonPathComponents[i]) !== getCanonicalFileName(sourcePathComponents[i])) { | ||
| if (i === 0) { | ||
| programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files)); | ||
| return; | ||
| // Failed to find any common path component | ||
| return true; | ||
| } | ||
|
|
||
| // New common path found that is 0 -> i-1 | ||
|
|
@@ -938,6 +938,11 @@ namespace ts { | |
| } | ||
| }); | ||
|
|
||
| // A common path can not be found when paths span multiple drives on windows, for example | ||
| if (failed) { | ||
| return ""; | ||
| } | ||
|
|
||
| if (!commonPathComponents) { // Can happen when all input files are .d.ts files | ||
| return currentDirectory; | ||
| } | ||
|
|
@@ -1059,6 +1064,10 @@ namespace ts { | |
| else { | ||
| // Compute the commonSourceDirectory from the input files | ||
| commonSourceDirectory = computeCommonSourceDirectory(files); | ||
| // If we failed to find a good common directory, but outDir is specified and at least one of our files is on a windows drive/URL/other resource, add a failure | ||
| if (options.outDir && commonSourceDirectory === "" && forEach(files, file => getRootLength(file.fileName) > 1)) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Aye, that works.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Scratch that, no - we're saying
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since if the root is a filesystem rooted at
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. but apparently we cannot do this since
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct - in effect, we want to allow
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. discussed offline |
||
| programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files)); | ||
| } | ||
| } | ||
|
|
||
| if (commonSourceDirectory && commonSourceDirectory[commonSourceDirectory.length - 1] !== directorySeparator) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| //// [tests/cases/compiler/commonSourceDir1.ts] //// | ||
|
|
||
| //// [bar.ts] | ||
| var x: number; | ||
|
|
||
| //// [baz.ts] | ||
| var y: number; | ||
|
|
||
|
|
||
| //// [bar.js] | ||
| var x; | ||
| //// [baz.js] | ||
| var y; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| === A:/foo/bar.ts === | ||
| var x: number; | ||
| >x : Symbol(x, Decl(bar.ts, 0, 3)) | ||
|
|
||
| === A:/foo/baz.ts === | ||
| var y: number; | ||
| >y : Symbol(y, Decl(baz.ts, 0, 3)) | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| === A:/foo/bar.ts === | ||
| var x: number; | ||
| >x : number | ||
|
|
||
| === A:/foo/baz.ts === | ||
| var y: number; | ||
| >y : number | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| error TS5009: Cannot find the common subdirectory path for the input files. | ||
|
|
||
|
|
||
| !!! error TS5009: Cannot find the common subdirectory path for the input files. | ||
| ==== A:/foo/bar.ts (0 errors) ==== | ||
| var x: number; | ||
|
|
||
| ==== B:/foo/baz.ts (0 errors) ==== | ||
| var y: number; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| //// [tests/cases/compiler/commonSourceDir2.ts] //// | ||
|
|
||
| //// [bar.ts] | ||
| var x: number; | ||
|
|
||
| //// [baz.ts] | ||
| var y: number; | ||
|
|
||
| //// [bar.js] | ||
| var x; | ||
| //// [baz.js] | ||
| var y; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| //// [tests/cases/compiler/commonSourceDir3.ts] //// | ||
|
|
||
| //// [bar.ts] | ||
| var x: number; | ||
|
|
||
| //// [baz.ts] | ||
| var y: number; | ||
|
|
||
| //// [bar.js] | ||
| var x; | ||
| //// [baz.js] | ||
| var y; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| === A:/foo/bar.ts === | ||
| var x: number; | ||
| >x : Symbol(x, Decl(bar.ts, 0, 3)) | ||
|
|
||
| === a:/foo/baz.ts === | ||
| var y: number; | ||
| >y : Symbol(y, Decl(baz.ts, 0, 3)) | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| === A:/foo/bar.ts === | ||
| var x: number; | ||
| >x : number | ||
|
|
||
| === a:/foo/baz.ts === | ||
| var y: number; | ||
| >y : number | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| error TS5009: Cannot find the common subdirectory path for the input files. | ||
|
|
||
|
|
||
| !!! error TS5009: Cannot find the common subdirectory path for the input files. | ||
| ==== A:/foo/bar.ts (0 errors) ==== | ||
| var x: number; | ||
|
|
||
| ==== a:/foo/baz.ts (0 errors) ==== | ||
| var y: number; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| //// [tests/cases/compiler/commonSourceDir4.ts] //// | ||
|
|
||
| //// [bar.ts] | ||
| var x: number; | ||
|
|
||
| //// [baz.ts] | ||
| var y: number; | ||
|
|
||
| //// [bar.js] | ||
| var x; | ||
| //// [baz.js] | ||
| var y; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| // @outDir: A:/ | ||
| // @Filename: A:/foo/bar.ts | ||
| var x: number; | ||
|
|
||
| // @Filename: A:/foo/baz.ts | ||
| var y: number; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| // @outDir: A:/ | ||
| // @Filename: A:/foo/bar.ts | ||
| var x: number; | ||
|
|
||
| // @Filename: B:/foo/baz.ts | ||
| var y: number; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| // @useCaseSensitiveFileNames: false | ||
| // @outDir: A:/ | ||
| // @Filename: A:/foo/bar.ts | ||
| var x: number; | ||
|
|
||
| // @Filename: a:/foo/baz.ts | ||
| var y: number; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| // @useCaseSensitiveFileNames: true | ||
| // @outDir: A:/ | ||
| // @Filename: A:/foo/bar.ts | ||
| var x: number; | ||
|
|
||
| // @Filename: a:/foo/baz.ts | ||
| var y: number; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting...I wonder why this was
forEachbefore. It seems like a labelledforwould have been more obvious.Regardless, it's convenient because it makes your change smaller.