From 8df8523a8fa43d3c720095588905b313d2b42f52 Mon Sep 17 00:00:00 2001 From: Alexander Date: Mon, 16 Dec 2019 22:42:18 +0200 Subject: [PATCH] show an error if --showConfig is enabled and tsconfig.json does not exist --- src/compiler/diagnosticMessages.json | 4 ++++ src/executeCommandLine/executeCommandLine.ts | 12 +++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 890e88f05eb08..d3b4a1dd2b8a5 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -3325,6 +3325,10 @@ "category": "Error", "code": 5080 }, + "Cannot find a tsconfig.json file at the current directory: {0}.": { + "category": "Error", + "code": 5081 + }, "Generates a sourcemap for each corresponding '.d.ts' file.": { "category": "Message", diff --git a/src/executeCommandLine/executeCommandLine.ts b/src/executeCommandLine/executeCommandLine.ts index 94d7a19f30e25..5c2bb814e45ef 100644 --- a/src/executeCommandLine/executeCommandLine.ts +++ b/src/executeCommandLine/executeCommandLine.ts @@ -240,9 +240,15 @@ namespace ts { } if (commandLine.fileNames.length === 0 && !configFileName) { - printVersion(sys); - printHelp(sys, getOptionsForHelp(commandLine)); - return sys.exit(ExitStatus.Success); + if (commandLine.options.showConfig) { + reportDiagnostic(createCompilerDiagnostic(Diagnostics.Cannot_find_a_tsconfig_json_file_at_the_current_directory_Colon_0, normalizePath(sys.getCurrentDirectory()))); + return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped); + } + else { + printVersion(sys); + printHelp(sys, getOptionsForHelp(commandLine)); + return sys.exit(ExitStatus.Success); + } } const currentDirectory = sys.getCurrentDirectory();