(sys tsc.System, input, output string)
| 63 | } |
| 64 | |
| 65 | func fmtMain(sys tsc.System, input, output string) tsc.ExitStatus { |
| 66 | ctx := format.WithFormatCodeSettings(context.Background(), lsutil.GetDefaultFormatCodeSettings(), "\n") |
| 67 | input = string(tspath.ToPath(input, sys.GetCurrentDirectory(), sys.FS().UseCaseSensitiveFileNames())) |
| 68 | output = string(tspath.ToPath(output, sys.GetCurrentDirectory(), sys.FS().UseCaseSensitiveFileNames())) |
| 69 | fileContent, ok := sys.FS().ReadFile(input) |
| 70 | if !ok { |
| 71 | fmt.Fprintln(sys.Writer(), "File not found:", input) |
| 72 | return tsc.ExitStatusNotImplemented |
| 73 | } |
| 74 | text := fileContent |
| 75 | pathified := tspath.ToPath(input, sys.GetCurrentDirectory(), true) |
| 76 | sourceFile := parser.ParseSourceFile(ast.SourceFileParseOptions{ |
| 77 | FileName: string(pathified), |
| 78 | Path: pathified, |
| 79 | }, text, core.GetScriptKindFromFileName(string(pathified))) |
| 80 | edits := format.FormatDocument(ctx, sourceFile) |
| 81 | newText := core.ApplyBulkEdits(text, edits) |
| 82 | |
| 83 | if err := sys.FS().WriteFile(output, newText); err != nil { |
| 84 | fmt.Fprintln(sys.Writer(), err.Error()) |
| 85 | return tsc.ExitStatusNotImplemented |
| 86 | } |
| 87 | return tsc.ExitStatusSuccess |
| 88 | } |
| 89 | |
| 90 | func tscBuildCompilation(ctx context.Context, sys tsc.System, buildCommand *tsoptions.ParsedBuildCommandLine, testing tsc.CommandLineTesting) tsc.CommandLineResult { |
| 91 | locale := buildCommand.Locale() |
nothing calls this directly
no test coverage detected