Skip to content
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

Change project option resolution #3102

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/compiler/commandLineParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ module ts {
shortName: "p",
type: "string",
isFilePath: true,
description: Diagnostics.Compile_the_project_in_the_given_directory,
paramType: Diagnostics.DIRECTORY
description: Diagnostics.Compile_the_project_by_specifying_a_project_file_or_its_directory,
paramType: Diagnostics.PATH
},
{
name: "removeComments",
Expand Down Expand Up @@ -308,7 +308,10 @@ module ts {
* Read tsconfig.json file
* @param fileName The path to the config file
*/
export function readConfigFile(fileName: string): { config?: any; error?: Diagnostic } {
export function readConfigFile(fileName: string): { config?: any; error?: Diagnostic } {
if (!sys.fileExists(fileName)) {
return { error: createCompilerDiagnostic(Diagnostics.Unable_to_open_file_0, fileName) };
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what regression are you referring to?

this line.

$ tsc -v
message TS6029: Version 1.5.0-beta
$ tsc --project ./not-exists/
error TS6050: Unable to open file 'not-exists/tsconfig.json'.

$ node ~/work/TypeScript/bin/tsc.js --project ./not-exists/
error TS5014: Failed to parse file 'not-exists/tsconfig.json': Unexpected token u.
# I think this is regression. error message is not easy to understanding.

$ node ~/work/TypeScript/built/local/tsc.js --project ./not-exists/
error TS6050: Unable to open file 'not-exists'.
# fixed by this change

}
try {
var text = sys.readFile(fileName);
}
Expand Down
3 changes: 2 additions & 1 deletion src/compiler/diagnosticInformationMap.generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ module ts {
Specify_module_code_generation_Colon_commonjs_amd_system_or_umd: { code: 6016, category: DiagnosticCategory.Message, key: "Specify module code generation: 'commonjs', 'amd', 'system' or 'umd'" },
Print_this_message: { code: 6017, category: DiagnosticCategory.Message, key: "Print this message." },
Print_the_compiler_s_version: { code: 6019, category: DiagnosticCategory.Message, key: "Print the compiler's version." },
Compile_the_project_in_the_given_directory: { code: 6020, category: DiagnosticCategory.Message, key: "Compile the project in the given directory." },
Compile_the_project_by_specifying_a_project_file_or_its_directory: { code: 6020, category: DiagnosticCategory.Message, key: "Compile the project by specifying a project file or its directory." },
Syntax_Colon_0: { code: 6023, category: DiagnosticCategory.Message, key: "Syntax: {0}" },
options: { code: 6024, category: DiagnosticCategory.Message, key: "options" },
file: { code: 6025, category: DiagnosticCategory.Message, key: "file" },
Expand All @@ -486,6 +486,7 @@ module ts {
VERSION: { code: 6036, category: DiagnosticCategory.Message, key: "VERSION" },
LOCATION: { code: 6037, category: DiagnosticCategory.Message, key: "LOCATION" },
DIRECTORY: { code: 6038, category: DiagnosticCategory.Message, key: "DIRECTORY" },
PATH: { code: 6039, category: DiagnosticCategory.Message, key: "PATH" },
Compilation_complete_Watching_for_file_changes: { code: 6042, category: DiagnosticCategory.Message, key: "Compilation complete. Watching for file changes." },
Generates_corresponding_map_file: { code: 6043, category: DiagnosticCategory.Message, key: "Generates corresponding '.map' file." },
Compiler_option_0_expects_an_argument: { code: 6044, category: DiagnosticCategory.Error, key: "Compiler option '{0}' expects an argument." },
Expand Down
6 changes: 5 additions & 1 deletion src/compiler/diagnosticMessages.json
Original file line number Diff line number Diff line change
Expand Up @@ -1878,7 +1878,7 @@
"category": "Message",
"code": 6019
},
"Compile the project in the given directory.": {
"Compile the project by specifying a project file or its directory.": {
"category": "Message",
"code": 6020
},
Expand Down Expand Up @@ -1934,6 +1934,10 @@
"category": "Message",
"code": 6038
},
"PATH": {
"category": "Message",
"code": 6039
},
"Compilation complete. Watching for file changes.": {
"category": "Message",
"code": 6042
Expand Down
8 changes: 7 additions & 1 deletion src/compiler/tsc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,13 @@ module ts {
reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--project"));
return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped);
}
configFileName = normalizePath(combinePaths(commandLine.options.project, "tsconfig.json"));
if (sys.directoryExists(commandLine.options.project)) {
configFileName = normalizePath(combinePaths(commandLine.options.project, "tsconfig.json"));
}
else {
configFileName = normalizePath(commandLine.options.project);
}

if (commandLine.fileNames.length !== 0) {
reportDiagnostic(createCompilerDiagnostic(Diagnostics.Option_project_cannot_be_mixed_with_source_files_on_a_command_line));
return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped);
Expand Down