-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathjsx.go
40 lines (32 loc) · 814 Bytes
/
jsx.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
package pork
import (
"os"
"os/exec"
"path/filepath"
)
func jsxCommand(c *Config, src, dst string) *exec.Cmd {
args := []string{"--output", dst}
for _, i := range c.JsxIncludes {
args = append(args, "--add-search-path", i)
}
switch c.Level {
case Basic:
args = append(args, "--release")
case Advanced:
args = append(args,
"--release",
"--optimize",
"no-assert,no-log,inline,return-if")
}
args = append(args, filepath.Base(src))
cm := exec.Command(PathToJsx, args...)
// For jsx, we execute with a difference cwd to avoid having
// absolute paths in the class map.
cm.Dir = filepath.Dir(src)
cm.Stderr = os.Stderr
cm.Stdout = os.Stdout
return cm
}
func CompileJsx(c *Config, src, dst string) error {
return jsxCommand(c, src, dst).Run()
}