#16 support for install and build
This commit is contained in:
parent
43653ad810
commit
0a4b5eb1be
10
cmd.go
10
cmd.go
@ -33,6 +33,8 @@ type Cmds struct {
|
||||
type Cmd struct {
|
||||
Status bool `yaml:"status,omitempty" json:"status,omitempty"`
|
||||
Args []string `yaml:"args,omitempty" json:"args,omitempty"`
|
||||
Method []string `yaml:"method,omitempty" json:"method,omitempty"`
|
||||
method []string
|
||||
name, startTxt, endTxt string
|
||||
}
|
||||
|
||||
@ -151,14 +153,16 @@ func (r *realize) run(p *cli.Context) error {
|
||||
// default settings
|
||||
r.Schema[k].Cmds.Install = Cmd{
|
||||
Status: elm.Cmds.Install.Status,
|
||||
Args: append([]string{"install"}, elm.Cmds.Install.Args...),
|
||||
Args: append([]string{}, elm.Cmds.Install.Args...),
|
||||
method: []string{"go", "install"},
|
||||
name: "Go Install",
|
||||
startTxt: "Installing...",
|
||||
endTxt: "Installed",
|
||||
}
|
||||
r.Schema[k].Cmds.Build = Cmd{
|
||||
Status: elm.Cmds.Build.Status,
|
||||
Args: append([]string{"build"}, elm.Cmds.Build.Args...),
|
||||
Args: append([]string{}, elm.Cmds.Build.Args...),
|
||||
method: []string{"go", "build"},
|
||||
name: "Go Build",
|
||||
startTxt: "Bulding...",
|
||||
endTxt: "Built",
|
||||
@ -206,7 +210,7 @@ func (r *realize) remove(p *cli.Context) error {
|
||||
return errors.New("no project found")
|
||||
}
|
||||
|
||||
// Insert a project if there isn't already one
|
||||
// Insert current project if there isn't already one
|
||||
func (r *realize) insert(c *cli.Context) error {
|
||||
if c.Bool("no-config") {
|
||||
r.Schema = []Project{}
|
||||
|
13
watcher.go
13
watcher.go
@ -21,12 +21,12 @@ var (
|
||||
wg sync.WaitGroup
|
||||
)
|
||||
|
||||
// Watcher struct defines the livereload's logic
|
||||
// Watch struct defines options for livereload
|
||||
type Watch struct {
|
||||
Preview bool `yaml:"preview,omitempty" json:"preview,omitempty"`
|
||||
Paths []string `yaml:"paths" json:"paths"`
|
||||
Exts []string `yaml:"extensions" json:"extensions"`
|
||||
Ignore []string `yaml:"ignored_paths,omitempty" json:"ignored_paths,omitempty"`
|
||||
Preview bool `yaml:"preview,omitempty" json:"preview,omitempty"`
|
||||
Scripts []Command `yaml:"scripts,omitempty" json:"scripts,omitempty"`
|
||||
}
|
||||
|
||||
@ -83,7 +83,7 @@ type BufferOut struct {
|
||||
Errors []string `json:"errors"`
|
||||
}
|
||||
|
||||
// Watch the project by fsnotify
|
||||
// Watch the project
|
||||
func (p *Project) watch() {
|
||||
p.watcher, _ = Watcher()
|
||||
stop, exit := make(chan bool), make(chan os.Signal, 2)
|
||||
@ -166,7 +166,7 @@ func (p *Project) err(err error) {
|
||||
p.stamp("error", out, msg, "")
|
||||
}
|
||||
|
||||
// Cmd calls an wrapper for execute the commands after/before
|
||||
// Cmd calls the method that execute commands after/before and display the results
|
||||
func (p *Project) cmd(stop <-chan bool, flag string, global bool) {
|
||||
done := make(chan bool)
|
||||
// cmds are scheduled in sequence
|
||||
@ -214,7 +214,10 @@ func (p *Project) compile(stop <-chan bool, cmd Cmd) error {
|
||||
channel := make(chan Result)
|
||||
go func() {
|
||||
log.Println(p.pname(p.Name, 1), ":", cmd.startTxt)
|
||||
stream, err := p.goCompile(stop, cmd.Args)
|
||||
if len(cmd.Method) > 0 {
|
||||
cmd.method = cmd.Method
|
||||
}
|
||||
stream, err := p.goCompile(stop, cmd.method, cmd.Args)
|
||||
if stream != "killed" {
|
||||
channel <- Result{stream, err}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user