double path field fixed
This commit is contained in:
parent
725783831f
commit
61d9efe90f
12
cmd.go
12
cmd.go
|
@ -7,6 +7,7 @@ import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"time"
|
"time"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Tool options customizable, should be moved in Cmd
|
// Tool options customizable, should be moved in Cmd
|
||||||
|
@ -117,10 +118,11 @@ func (r *realize) run(p *cli.Context) error {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
// validate project path, if invalid get wdir or clean current
|
// validate project path, if invalid get wdir or clean current
|
||||||
if !filepath.IsAbs(elm.path){
|
if !filepath.IsAbs(elm.Path){
|
||||||
r.Schema[k].path = wdir()
|
r.Schema[k].Path = wdir()
|
||||||
}else{
|
}else{
|
||||||
r.Schema[k].path = filepath.Clean(elm.path)
|
r.Schema[k].Path = filepath.Clean(elm.Path)
|
||||||
|
fmt.Println(r.Schema[k].Path )
|
||||||
}
|
}
|
||||||
// env variables
|
// env variables
|
||||||
for key, item := range r.Schema[k].Environment {
|
for key, item := range r.Schema[k].Environment {
|
||||||
|
@ -129,7 +131,7 @@ func (r *realize) run(p *cli.Context) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// get basepath name
|
// get basepath name
|
||||||
r.Schema[k].name = filepath.Base(r.Schema[k].path)
|
r.Schema[k].name = filepath.Base(r.Schema[k].Path)
|
||||||
|
|
||||||
fields := reflect.Indirect(reflect.ValueOf(&r.Schema[k].Cmds))
|
fields := reflect.Indirect(reflect.ValueOf(&r.Schema[k].Cmds))
|
||||||
// Loop struct Cmds fields
|
// Loop struct Cmds fields
|
||||||
|
@ -210,9 +212,7 @@ func (r *realize) run(p *cli.Context) error {
|
||||||
startTxt: "Building...",
|
startTxt: "Building...",
|
||||||
endTxt: "Built",
|
endTxt: "Built",
|
||||||
}
|
}
|
||||||
|
|
||||||
r.Schema[k].parent = r
|
r.Schema[k].parent = r
|
||||||
r.Schema[k].path = r.Schema[k].Path
|
|
||||||
|
|
||||||
match = true
|
match = true
|
||||||
go r.Schema[k].watch()
|
go r.Schema[k].watch()
|
||||||
|
|
12
exec.go
12
exec.go
|
@ -22,7 +22,7 @@ func (p *Project) goCompile(stop <-chan bool, method []string, args []string) (s
|
||||||
done := make(chan error)
|
done := make(chan error)
|
||||||
args = append(method, args...)
|
args = append(method, args...)
|
||||||
cmd := exec.Command(args[0], args[1:]...)
|
cmd := exec.Command(args[0], args[1:]...)
|
||||||
cmd.Dir = p.path
|
cmd.Dir = p.Path
|
||||||
cmd.Stdout = &out
|
cmd.Stdout = &out
|
||||||
cmd.Stderr = &stderr
|
cmd.Stderr = &stderr
|
||||||
// Start command
|
// Start command
|
||||||
|
@ -79,7 +79,7 @@ func (p *Project) goRun(stop <-chan bool, runner chan bool) {
|
||||||
} else if _, err := os.Stat(path + extWindows); err == nil {
|
} else if _, err := os.Stat(path + extWindows); err == nil {
|
||||||
build = exec.Command(path+extWindows, args...)
|
build = exec.Command(path+extWindows, args...)
|
||||||
} else {
|
} else {
|
||||||
path := filepath.Join(p.path, p.name)
|
path := filepath.Join(p.Path, p.name)
|
||||||
if _, err = os.Stat(path); err == nil {
|
if _, err = os.Stat(path); err == nil {
|
||||||
build = exec.Command(path, args...)
|
build = exec.Command(path, args...)
|
||||||
} else if _, err = os.Stat(path + extWindows); err == nil {
|
} else if _, err = os.Stat(path + extWindows); err == nil {
|
||||||
|
@ -150,13 +150,13 @@ func (p *Project) command(stop <-chan bool, cmd Command) (string, string) {
|
||||||
done := make(chan error)
|
done := make(chan error)
|
||||||
args := strings.Split(strings.Replace(strings.Replace(cmd.Command, "'", "", -1), "\"", "", -1), " ")
|
args := strings.Split(strings.Replace(strings.Replace(cmd.Command, "'", "", -1), "\"", "", -1), " ")
|
||||||
exec := exec.Command(args[0], args[1:]...)
|
exec := exec.Command(args[0], args[1:]...)
|
||||||
exec.Dir = p.path
|
exec.Dir = p.Path
|
||||||
// make cmd path
|
// make cmd path
|
||||||
if cmd.Path != "" {
|
if cmd.Path != "" {
|
||||||
if strings.Contains(cmd.Path, p.path) {
|
if strings.Contains(cmd.Path, p.Path) {
|
||||||
exec.Dir = cmd.Path
|
exec.Dir = cmd.Path
|
||||||
} else {
|
} else {
|
||||||
exec.Dir = filepath.Join(p.path, cmd.Path)
|
exec.Dir = filepath.Join(p.Path, cmd.Path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exec.Stdout = &stdout
|
exec.Stdout = &stdout
|
||||||
|
@ -189,7 +189,7 @@ func (p *Project) goTool(wg *sync.WaitGroup, stop <-chan bool, result chan<- too
|
||||||
if strings.HasSuffix(path, ".go") || strings.HasSuffix(path, "") {
|
if strings.HasSuffix(path, ".go") || strings.HasSuffix(path, "") {
|
||||||
if strings.HasSuffix(path, ".go") {
|
if strings.HasSuffix(path, ".go") {
|
||||||
tool.options = append(tool.options, path)
|
tool.options = append(tool.options, path)
|
||||||
path = p.path
|
path = p.Path
|
||||||
}
|
}
|
||||||
if s := ext(path); s == "" || s == "go" {
|
if s := ext(path); s == "" || s == "go" {
|
||||||
var out, stderr bytes.Buffer
|
var out, stderr bytes.Buffer
|
||||||
|
|
12
watcher.go
12
watcher.go
|
@ -55,7 +55,7 @@ type Project struct {
|
||||||
watcher FileWatcher
|
watcher FileWatcher
|
||||||
init bool
|
init bool
|
||||||
files, folders int64
|
files, folders int64
|
||||||
name, path, lastFile string
|
name, lastFile string
|
||||||
tools []tool
|
tools []tool
|
||||||
paths []string
|
paths []string
|
||||||
lastTime time.Time
|
lastTime time.Time
|
||||||
|
@ -98,7 +98,7 @@ func (p *Project) watch() {
|
||||||
p.cmd(stop, "before", true)
|
p.cmd(stop, "before", true)
|
||||||
// indexing files and dirs
|
// indexing files and dirs
|
||||||
for _, dir := range p.Watcher.Paths {
|
for _, dir := range p.Watcher.Paths {
|
||||||
base := filepath.Join(p.path, dir)
|
base := filepath.Join(p.Path, dir)
|
||||||
if _, err := os.Stat(base); err == nil {
|
if _, err := os.Stat(base); err == nil {
|
||||||
if err := filepath.Walk(base, p.walk); err == nil {
|
if err := filepath.Walk(base, p.walk); err == nil {
|
||||||
p.tool(stop, base)
|
p.tool(stop, base)
|
||||||
|
@ -312,7 +312,7 @@ func (p *Project) changed(event fsnotify.Event, stop chan bool) {
|
||||||
// Watch the files tree of a project
|
// Watch the files tree of a project
|
||||||
func (p *Project) walk(path string, info os.FileInfo, err error) error {
|
func (p *Project) walk(path string, info os.FileInfo, err error) error {
|
||||||
for _, v := range p.Watcher.Ignore {
|
for _, v := range p.Watcher.Ignore {
|
||||||
s := append([]string{p.path},strings.Split(v,string(os.PathSeparator))...)
|
s := append([]string{p.Path},strings.Split(v,string(os.PathSeparator))...)
|
||||||
if strings.Contains(path, filepath.Join(s...)) {
|
if strings.Contains(path, filepath.Join(s...)) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -339,7 +339,7 @@ func (p *Project) stamp(t string, o BufferOut, msg string, stream string) {
|
||||||
case "out":
|
case "out":
|
||||||
p.Buffer.StdOut = append(p.Buffer.StdOut, o)
|
p.Buffer.StdOut = append(p.Buffer.StdOut, o)
|
||||||
if p.Files.Outputs.Status {
|
if p.Files.Outputs.Status {
|
||||||
f := p.create(p.path, p.Files.Outputs.Name)
|
f := p.create(p.Path, p.Files.Outputs.Name)
|
||||||
t := time.Now()
|
t := time.Now()
|
||||||
s := []string{t.Format("2006-01-02 15:04:05"), strings.ToUpper(p.Name), ":", o.Text, "\r\n"}
|
s := []string{t.Format("2006-01-02 15:04:05"), strings.ToUpper(p.Name), ":", o.Text, "\r\n"}
|
||||||
if _, err := f.WriteString(strings.Join(s, " ")); err != nil {
|
if _, err := f.WriteString(strings.Join(s, " ")); err != nil {
|
||||||
|
@ -349,7 +349,7 @@ func (p *Project) stamp(t string, o BufferOut, msg string, stream string) {
|
||||||
case "log":
|
case "log":
|
||||||
p.Buffer.StdLog = append(p.Buffer.StdLog, o)
|
p.Buffer.StdLog = append(p.Buffer.StdLog, o)
|
||||||
if p.Files.Logs.Status {
|
if p.Files.Logs.Status {
|
||||||
f := p.create(p.path, p.Files.Logs.Name)
|
f := p.create(p.Path, p.Files.Logs.Name)
|
||||||
t := time.Now()
|
t := time.Now()
|
||||||
s := []string{t.Format("2006-01-02 15:04:05"), strings.ToUpper(p.Name), ":", o.Text, "\r\n"}
|
s := []string{t.Format("2006-01-02 15:04:05"), strings.ToUpper(p.Name), ":", o.Text, "\r\n"}
|
||||||
if stream != "" {
|
if stream != "" {
|
||||||
|
@ -362,7 +362,7 @@ func (p *Project) stamp(t string, o BufferOut, msg string, stream string) {
|
||||||
case "error":
|
case "error":
|
||||||
p.Buffer.StdErr = append(p.Buffer.StdErr, o)
|
p.Buffer.StdErr = append(p.Buffer.StdErr, o)
|
||||||
if p.Files.Errors.Status {
|
if p.Files.Errors.Status {
|
||||||
f := p.create(p.path, p.Files.Errors.Name)
|
f := p.create(p.Path, p.Files.Errors.Name)
|
||||||
t := time.Now()
|
t := time.Now()
|
||||||
s := []string{t.Format("2006-01-02 15:04:05"), strings.ToUpper(p.Name), ":", o.Type, o.Text, o.Path, "\r\n"}
|
s := []string{t.Format("2006-01-02 15:04:05"), strings.ToUpper(p.Name), ":", o.Type, o.Text, o.Path, "\r\n"}
|
||||||
if stream != "" {
|
if stream != "" {
|
||||||
|
|
Loading…
Reference in New Issue