Skip to content

Commit 2a21558

Browse files
committed
Merge pull request #4883 from SaschaNaz/tsconfigpath
Support full path for -project/-p paramater
2 parents ea0cc79 + 880db38 commit 2a21558

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

src/compiler/diagnosticMessages.json

+9-1
Original file line numberDiff line numberDiff line change
@@ -1622,7 +1622,7 @@
16221622
},
16231623
"Cannot assign an abstract constructor type to a non-abstract constructor type.": {
16241624
"category": "Error",
1625-
"code":2517
1625+
"code": 2517
16261626
},
16271627
"Duplicate identifier '{0}'. Compiler uses declaration '{1}' to support async functions.": {
16281628
"category": "Error",
@@ -2068,6 +2068,14 @@
20682068
"category": "Error",
20692069
"code": 5056
20702070
},
2071+
"Cannot find a tsconfig.json file at the specified directory: '{0}'": {
2072+
"category": "Error",
2073+
"code": 5057
2074+
},
2075+
"The specified path does not exist: '{0}'": {
2076+
"category": "Error",
2077+
"code": 5058
2078+
},
20712079

20722080
"Concatenate and emit output to single file.": {
20732081
"category": "Message",

src/compiler/tsc.ts

+16-1
Original file line numberDiff line numberDiff line change
@@ -295,11 +295,26 @@ namespace ts {
295295
reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--project"), /* compilerHost */ undefined);
296296
return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped);
297297
}
298-
configFileName = normalizePath(combinePaths(commandLine.options.project, "tsconfig.json"));
299298
if (commandLine.fileNames.length !== 0) {
300299
reportDiagnostic(createCompilerDiagnostic(Diagnostics.Option_project_cannot_be_mixed_with_source_files_on_a_command_line), /* compilerHost */ undefined);
301300
return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped);
302301
}
302+
303+
const fileOrDirectory = normalizePath(commandLine.options.project);
304+
if (!fileOrDirectory /* current directory "." */ || sys.directoryExists(fileOrDirectory)) {
305+
configFileName = combinePaths(fileOrDirectory, "tsconfig.json");
306+
if (!sys.fileExists(configFileName)) {
307+
reportDiagnostic(createCompilerDiagnostic(Diagnostics.Cannot_find_a_tsconfig_json_file_at_the_specified_directory_Colon_0, commandLine.options.project), /* compilerHost */ undefined);
308+
return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped);
309+
}
310+
}
311+
else {
312+
configFileName = fileOrDirectory;
313+
if (!sys.fileExists(configFileName)) {
314+
reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_specified_path_does_not_exist_Colon_0, commandLine.options.project), /* compilerHost */ undefined);
315+
return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped);
316+
}
317+
}
303318
}
304319
else if (commandLine.fileNames.length === 0 && isJSONSupported()) {
305320
const searchPath = normalizePath(sys.getCurrentDirectory());

0 commit comments

Comments
 (0)