dnscontrol/build/generate/dtsFile.go
Jed Fox 9b3ad81b1d
Embed types-dnscontrol.d.ts into the binary instead of fetching it via HTTP (#1942)
Co-authored-by: Tom Limoncelli <tlimoncelli@stackoverflow.com>
2023-01-17 12:10:43 -05:00

29 lines
617 B
Go

package main
import (
"os"
"strings"
)
func generateDTSFile(funcs string) error {
names := []string{
"base-types",
"fetch",
"others",
}
combined := []string{
"// WARNING: These type definitions are experimental and subject to change in future releases.",
}
for _, name := range names {
content, err := os.ReadFile(join("commands", "types", name+".d.ts"))
if err != nil {
return err
}
combined = append(combined, string(content))
}
combined = append(combined, funcs)
os.WriteFile(join("commands", "types", "dnscontrol.d.ts"), []byte(strings.Join(combined, "\n\n")), 0644)
return nil
}