MCPcopy Index your code
hub / github.com/TypeScriptToLua/TypeScriptToLua / executeCommandLine

Function executeCommandLine

src/tstl.ts:24–86  ·  view source on GitHub ↗
(args: string[])

Source from the content-addressed store, hash-verified

22}
23
24function 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);

Callers 1

tstl.tsFile · 0.85

Calls 10

parseCommandLineFunction · 0.90
getHelpStringFunction · 0.90
locateConfigFileFunction · 0.90
performBuildFunction · 0.85
updateReportDiagnosticFunction · 0.85
createWatchOfConfigFileFunction · 0.85
performCompilationFunction · 0.85
forEachMethod · 0.45

Tested by

no test coverage detected