blob: 6ad213d3edf707a0167ebbd0796e4bdb2c2dac98 (
plain)
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
43
44
45
46
47
48
49
50
51
52
53
54
55
|
package js
import (
"github.com/ewy1/pik/describe"
"github.com/ewy1/pik/model"
"github.com/ewy1/pik/runner"
"github.com/ewy1/pik/spool"
"os/exec"
"path/filepath"
)
type Script struct {
runner.BaseTarget
Typed bool
}
func (t *Script) Icon() string {
if t.Typed {
return "\uE628"
} else {
return "\uE60C"
}
}
func (t *Script) Description(src *model.HydratedSource) string {
d, err := describe.Describe(t, t.File(src.Source))
if err != nil {
_, _ = spool.Warn("%v\n", err)
}
return d
}
func (t *Script) Target() model.Target {
return t
}
func (t *Script) Create(s *model.Source) *exec.Cmd {
if t.Typed {
return exec.Command(Js.TsInterpreter, t.File(s))
} else {
return exec.Command(Js.JsInterpreter, t.File(s))
}
}
func (t *Script) Label() string {
return t.Identity.Full
}
func (t *Script) Hydrate(src *model.Source) (model.HydratedTarget, error) {
return t, nil
}
func (t *Script) File(src *model.Source) string {
return filepath.Join(src.Path, "package.json")
}
|