(ctx context.Context, sys tsc.System, commandLine *tsoptions.ParsedCommandLine, testing tsc.CommandLineTesting)
| 119 | } |
| 120 | |
| 121 | func tscCompilation(ctx context.Context, sys tsc.System, commandLine *tsoptions.ParsedCommandLine, testing tsc.CommandLineTesting) tsc.CommandLineResult { |
| 122 | configFileName := "" |
| 123 | locale := commandLine.Locale() |
| 124 | reportDiagnostic := tsc.CreateDiagnosticReporter(sys, sys.Writer(), locale, commandLine.CompilerOptions()) |
| 125 | |
| 126 | if len(commandLine.Errors) > 0 { |
| 127 | for _, e := range commandLine.Errors { |
| 128 | reportDiagnostic(e) |
| 129 | } |
| 130 | return tsc.CommandLineResult{Status: tsc.ExitStatusDiagnosticsPresent_OutputsSkipped} |
| 131 | } |
| 132 | |
| 133 | if pprofDir := commandLine.CompilerOptions().PprofDir; pprofDir != "" { |
| 134 | // !!! stderr? |
| 135 | profileSession := pprof.BeginProfiling(pprofDir, sys.Writer()) |
| 136 | defer profileSession.Stop() |
| 137 | } |
| 138 | |
| 139 | if commandLine.CompilerOptions().Init.IsTrue() { |
| 140 | tsc.WriteConfigFile(sys, locale, reportDiagnostic, commandLine.Raw.(*collections.OrderedMap[string, any])) |
| 141 | return tsc.CommandLineResult{Status: tsc.ExitStatusSuccess} |
| 142 | } |
| 143 | |
| 144 | if commandLine.CompilerOptions().Version.IsTrue() { |
| 145 | tsc.PrintVersion(sys, locale) |
| 146 | return tsc.CommandLineResult{Status: tsc.ExitStatusSuccess} |
| 147 | } |
| 148 | |
| 149 | if commandLine.CompilerOptions().Help.IsTrue() || commandLine.CompilerOptions().All.IsTrue() { |
| 150 | tsc.PrintHelp(sys, locale, commandLine) |
| 151 | return tsc.CommandLineResult{Status: tsc.ExitStatusSuccess} |
| 152 | } |
| 153 | |
| 154 | if commandLine.CompilerOptions().Watch.IsTrue() && commandLine.CompilerOptions().ListFilesOnly.IsTrue() { |
| 155 | reportDiagnostic(ast.NewCompilerDiagnostic(diagnostics.Options_0_and_1_cannot_be_combined, "watch", "listFilesOnly")) |
| 156 | return tsc.CommandLineResult{Status: tsc.ExitStatusDiagnosticsPresent_OutputsSkipped} |
| 157 | } |
| 158 | |
| 159 | if commandLine.CompilerOptions().Project != "" { |
| 160 | if len(commandLine.FileNames()) != 0 { |
| 161 | reportDiagnostic(ast.NewCompilerDiagnostic(diagnostics.Option_project_cannot_be_mixed_with_source_files_on_a_command_line)) |
| 162 | return tsc.CommandLineResult{Status: tsc.ExitStatusDiagnosticsPresent_OutputsSkipped} |
| 163 | } |
| 164 | |
| 165 | fileOrDirectory := tspath.NormalizePath(commandLine.CompilerOptions().Project) |
| 166 | if sys.FS().DirectoryExists(fileOrDirectory) { |
| 167 | configFileName = tspath.CombinePaths(fileOrDirectory, "tsconfig.json") |
| 168 | if !sys.FS().FileExists(configFileName) { |
| 169 | reportDiagnostic(ast.NewCompilerDiagnostic(diagnostics.Cannot_find_a_tsconfig_json_file_at_the_current_directory_Colon_0, configFileName)) |
| 170 | return tsc.CommandLineResult{Status: tsc.ExitStatusDiagnosticsPresent_OutputsSkipped} |
| 171 | } |
| 172 | } else { |
| 173 | configFileName = fileOrDirectory |
| 174 | if !sys.FS().FileExists(configFileName) { |
| 175 | reportDiagnostic(ast.NewCompilerDiagnostic(diagnostics.The_specified_path_does_not_exist_Colon_0, fileOrDirectory)) |
| 176 | return tsc.CommandLineResult{Status: tsc.ExitStatusDiagnosticsPresent_OutputsSkipped} |
| 177 | } |
| 178 | } |
no test coverage detected