(args: string[])
| 22 | } |
| 23 | |
| 24 | function executeCommandLine(args: string[]): void { |
| 25 | if (args.length > 0 && args[0].startsWith("-")) { |
| 26 | const firstOption = args[0].slice(args[0].startsWith("--") ? 2 : 1).toLowerCase(); |
| 27 | if (firstOption === "build" || firstOption === "b") { |
| 28 | return performBuild(args.slice(1)); |
| 29 | } |
| 30 | } |
| 31 | |
| 32 | const commandLine = parseCommandLine(args); |
| 33 | |
| 34 | if (commandLine.options.build) { |
| 35 | reportDiagnostic(cliDiagnostics.optionBuildMustBeFirstCommandLineArgument()); |
| 36 | return ts.sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped); |
| 37 | } |
| 38 | |
| 39 | // TODO: ParsedCommandLine.errors isn't meant to contain warnings. Once root-level options |
| 40 | // support would be dropped it should be changed to `commandLine.errors.length > 0`. |
| 41 | if (commandLine.errors.some(e => e.category === ts.DiagnosticCategory.Error)) { |
| 42 | commandLine.errors.forEach(reportDiagnostic); |
| 43 | return ts.sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped); |
| 44 | } |
| 45 | |
| 46 | if (commandLine.options.version) { |
| 47 | console.log(versionString); |
| 48 | return ts.sys.exit(ts.ExitStatus.Success); |
| 49 | } |
| 50 | |
| 51 | if (commandLine.options.help) { |
| 52 | console.log(versionString); |
| 53 | console.log(getHelpString()); |
| 54 | return ts.sys.exit(ts.ExitStatus.Success); |
| 55 | } |
| 56 | |
| 57 | const configFileName = locateConfigFile(commandLine); |
| 58 | if (typeof configFileName === "object") { |
| 59 | reportDiagnostic(configFileName); |
| 60 | return ts.sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped); |
| 61 | } |
| 62 | |
| 63 | const commandLineOptions = commandLine.options; |
| 64 | if (configFileName) { |
| 65 | const configParseResult = parseConfigFileWithSystem(configFileName, commandLineOptions); |
| 66 | |
| 67 | updateReportDiagnostic(configParseResult.options); |
| 68 | if (configParseResult.options.watch) { |
| 69 | createWatchOfConfigFile(configFileName, commandLineOptions); |
| 70 | } else { |
| 71 | performCompilation( |
| 72 | configParseResult.fileNames, |
| 73 | configParseResult.projectReferences, |
| 74 | configParseResult.options, |
| 75 | ts.getConfigFileParsingDiagnostics(configParseResult) |
| 76 | ); |
| 77 | } |
| 78 | } else { |
| 79 | updateReportDiagnostic(commandLineOptions); |
| 80 | if (commandLineOptions.watch) { |
| 81 | createWatchOfFilesAndCompilerOptions(commandLine.fileNames, commandLineOptions); |
no test coverage detected