MCPcopy Create free account
hub / github.com/microsoft/typescript-go / WriteConfigFile

Function WriteConfigFile

internal/execute/tsc/init.go:19–31  ·  view source on GitHub ↗
(sys System, locale locale.Locale, reportDiagnostic DiagnosticReporter, options *collections.OrderedMap[string, any])

Source from the content-addressed store, hash-verified

17)
18
19func WriteConfigFile(sys System, locale locale.Locale, reportDiagnostic DiagnosticReporter, options *collections.OrderedMap[string, any]) {
20 getCurrentDirectory := sys.GetCurrentDirectory()
21 file := tspath.NormalizePath(tspath.CombinePaths(getCurrentDirectory, "tsconfig.json"))
22 if sys.FS().FileExists(file) {
23 reportDiagnostic(ast.NewCompilerDiagnostic(diagnostics.A_tsconfig_json_file_is_already_defined_at_Colon_0, file))
24 } else {
25 _ = sys.FS().WriteFile(file, generateTSConfig(options, locale))
26 output := []string{"\n"}
27 output = append(output, getHeader(sys, "Created a new tsconfig.json")...)
28 output = append(output, "You can learn more at https://aka.ms/tsconfig", "\n")
29 fmt.Fprint(sys.Writer(), strings.Join(output, ""))
30 }
31}
32
33func generateTSConfig(options *collections.OrderedMap[string, any], locale locale.Locale) string {
34 const tab = " "

Callers 1

tscCompilationFunction · 0.92

Calls 11

NormalizePathFunction · 0.92
CombinePathsFunction · 0.92
NewCompilerDiagnosticFunction · 0.92
generateTSConfigFunction · 0.85
getHeaderFunction · 0.85
GetCurrentDirectoryMethod · 0.65
FileExistsMethod · 0.65
FSMethod · 0.65
WriteFileMethod · 0.65
WriterMethod · 0.65
appendFunction · 0.50

Tested by

no test coverage detected