This commit is contained in:
asoseil 2018-04-14 16:15:03 +02:00
parent 600b1ac467
commit f0e28d1602
4 changed files with 19 additions and 14 deletions

View File

@ -1,8 +1,8 @@
package main
import (
"github.com/tockins/interact"
"github.com/tockins/realize/realize"
"github.com/oxequa/interact"
"github.com/oxequa/realize/realize"
"gopkg.in/urfave/cli.v2"
"log"
"os"

View File

@ -26,7 +26,7 @@ var (
// Watch info
type Watch struct {
Exts []string `yaml:"exts" json:"exts"`
Exts []string `yaml:"extensions" json:"extensions"`
Paths []string `yaml:"paths" json:"paths"`
Scripts []Command `yaml:"scripts,omitempty" json:"scripts,omitempty"`
Hidden bool `yaml:"hidden,omitempty" json:"hidden,omitempty"`
@ -40,7 +40,7 @@ type Ignore struct{
// Command fields
type Command struct {
Cmd string `yaml:"cmd" json:"cmd"`
Cmd string `yaml:"command" json:"command"`
Type string `yaml:"type" json:"type"`
Path string `yaml:"path,omitempty" json:"path,omitempty"`
Global bool `yaml:"global,omitempty" json:"global,omitempty"`
@ -62,7 +62,7 @@ type Project struct {
Path string `yaml:"path" json:"path"`
Env map[string]string `yaml:"env,omitempty" json:"env,omitempty"`
Args []string `yaml:"args,omitempty" json:"args,omitempty"`
Tools Tools `yaml:"tools" json:"tools"`
Tools Tools `yaml:"commands" json:"commands"`
Watcher Watch `yaml:"watcher" json:"watcher"`
Buffer Buffer `yaml:"-" json:"buffer"`
ErrPattern string `yaml:"pattern,omitempty" json:"pattern,omitempty"`
@ -196,7 +196,7 @@ func (p *Project) Reload(path string, stop <-chan bool) {
}
// Go supported tools
if len(path) > 0 {
fi, err := os.Stat(filepath.Dir(path))
fi, err := os.Stat(path)
if filepath.Ext(path) == "" {
fi, err = os.Stat(path)
}
@ -497,9 +497,9 @@ func (p *Project) walk(path string, info os.FileInfo, err error) error {
if p.parent.Settings.Recovery.Index {
log.Println("Indexing",path)
}
p.tools(p.stop, path, info)
if info.IsDir() {
// tools dir
p.tools(p.stop, path, info)
p.folders++
} else {
// tools files
@ -544,7 +544,7 @@ func (p *Project) stamp(t string, o BufferOut, msg string, stream string) {
log.Print(msg)
}
if stream != "" {
fmt.Fprint(Output, stream)
fmt.Fprintln(Output, stream)
}
go func() {
p.parent.Sync <- "sync"

View File

@ -43,7 +43,7 @@ func (t *Tools) Setup() {
if t.Clean.Status {
t.Clean.name = "Clean"
t.Clean.isTool = true
t.Clean.cmd = replace([]string{"go clean"}, t.Clean.Method)
t.Clean.cmd = replace([]string{"go", "clean"}, t.Clean.Method)
t.Clean.Args = split([]string{}, t.Clean.Args)
}
// go generate
@ -134,7 +134,12 @@ func (t *Tool) Exec(path string, stop <-chan bool) (response Response) {
cmd.Stdout = &out
cmd.Stderr = &stderr
// Start command
cmd.Start()
err := cmd.Start()
if err != nil{
response.Name = t.name
response.Err = err
return
}
go func() { done <- cmd.Wait() }()
// Wait a result
select {
@ -145,7 +150,7 @@ func (t *Tool) Exec(path string, stop <-chan bool) (response Response) {
// Command completed
response.Name = t.name
if err != nil {
response.Err = errors.New(stderr.String() + out.String())
response.Err = errors.New(stderr.String() + out.String() + err.Error())
} else {
if t.Output {
response.Out = out.String()

View File

@ -3,7 +3,7 @@ package main
import (
"bytes"
"errors"
"github.com/tockins/realize/realize"
"github.com/oxequa/realize/realize"
"log"
"strings"
"testing"