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