/
cli_helpers.go
42 lines (38 loc) · 954 Bytes
/
cli_helpers.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// This package contains internal CLI-related code that must be shared with
// other internal code outside of the CLI package.
package cli_helpers
import (
"fmt"
"github.com/evanw/esbuild/pkg/api"
)
func ParseLoader(text string) (api.Loader, error) {
switch text {
case "js":
return api.LoaderJS, nil
case "jsx":
return api.LoaderJSX, nil
case "ts":
return api.LoaderTS, nil
case "tsx":
return api.LoaderTSX, nil
case "css":
return api.LoaderCSS, nil
case "json":
return api.LoaderJSON, nil
case "text":
return api.LoaderText, nil
case "base64":
return api.LoaderBase64, nil
case "dataurl":
return api.LoaderDataURL, nil
case "file":
return api.LoaderFile, nil
case "binary":
return api.LoaderBinary, nil
case "default":
return api.LoaderDefault, nil
default:
return api.LoaderNone, fmt.Errorf("Invalid loader: %q (valid: "+
"js, jsx, ts, tsx, css, json, text, base64, dataurl, file, binary)", text)
}
}