#118 fixed
This commit is contained in:
parent
49b574813c
commit
cf97995848
21
cmd.go
21
cmd.go
|
@ -43,6 +43,8 @@ func (r *realize) clean() error {
|
|||
arr := r.Schema
|
||||
for key, val := range arr {
|
||||
if _, err := duplicates(val, arr[key+1:]); err != nil {
|
||||
// path validation
|
||||
|
||||
r.Schema = append(arr[:key], arr[key+1:]...)
|
||||
break
|
||||
}
|
||||
|
@ -54,21 +56,14 @@ func (r *realize) clean() error {
|
|||
|
||||
// Add a new project
|
||||
func (r *realize) add(p *cli.Context) (err error) {
|
||||
var path string
|
||||
// #118 get relative and if not exist try to get abs
|
||||
if _, err = os.Stat(p.String("path")); os.IsNotExist(err) {
|
||||
// path doesn't exist
|
||||
path, err = filepath.Abs(p.String("path"))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
path = filepath.Clean(p.String("path"))
|
||||
// project init
|
||||
name := filepath.Base(p.String("path"))
|
||||
if name == "." {
|
||||
name = filepath.Base(wdir())
|
||||
}
|
||||
|
||||
project := Project{
|
||||
Name: filepath.Base(wdir()),
|
||||
Path: path,
|
||||
Name: name,
|
||||
Path: p.String("path"),
|
||||
Cmds: Cmds{
|
||||
Vet: Cmd{
|
||||
Status: p.Bool("vet"),
|
||||
|
|
8
exec.go
8
exec.go
|
@ -48,7 +48,6 @@ func (p *Project) goCompile(stop <-chan bool, method []string, args []string) (s
|
|||
func (p *Project) goRun(stop <-chan bool, runner chan bool) {
|
||||
var build *exec.Cmd
|
||||
var args []string
|
||||
|
||||
// custom error pattern
|
||||
isErrorText := func(string) bool {
|
||||
return false
|
||||
|
@ -73,13 +72,16 @@ func (p *Project) goRun(stop <-chan bool, runner chan bool) {
|
|||
}
|
||||
|
||||
gobin := os.Getenv("GOBIN")
|
||||
path := filepath.Join(gobin, p.name)
|
||||
dirPath := filepath.Base(p.Path)
|
||||
if p.Path == "." {
|
||||
dirPath = filepath.Base(wdir())
|
||||
}
|
||||
path := filepath.Join(gobin, dirPath)
|
||||
if _, err := os.Stat(path); err == nil {
|
||||
build = exec.Command(path, args...)
|
||||
} else if _, err := os.Stat(path + extWindows); err == nil {
|
||||
build = exec.Command(path+extWindows, args...)
|
||||
} else {
|
||||
path := filepath.Join(p.Path, p.name)
|
||||
if _, err = os.Stat(path); err == nil {
|
||||
build = exec.Command(path, args...)
|
||||
} else if _, err = os.Stat(path + extWindows); err == nil {
|
||||
|
|
|
@ -187,12 +187,6 @@ func (p *Project) err(err error) {
|
|||
|
||||
// Config project init
|
||||
func (p *Project) config(r *realize) {
|
||||
// validate project path, if invalid get wdir or clean current
|
||||
if !filepath.IsAbs(p.Path) {
|
||||
p.Path = wdir()
|
||||
} else {
|
||||
p.Path = filepath.Clean(p.Path)
|
||||
}
|
||||
// get basepath name
|
||||
p.name = filepath.Base(p.Path)
|
||||
// env variables
|
||||
|
|
Loading…
Reference in New Issue