Merge pull request #179 from noomz/master

Replace Tool.Dir with new property Tool.Path
This commit is contained in:
Alessio Pracchia 2018-05-07 15:47:01 +02:00 committed by GitHub
commit 17b324d363
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 7 deletions

View File

@ -5,7 +5,6 @@ import (
"bytes" "bytes"
"errors" "errors"
"fmt" "fmt"
"github.com/fsnotify/fsnotify"
"log" "log"
"math/big" "math/big"
"os" "os"
@ -17,6 +16,8 @@ import (
"strings" "strings"
"sync" "sync"
"time" "time"
"github.com/fsnotify/fsnotify"
) )
var ( var (
@ -586,18 +587,18 @@ func (p *Project) run(path string, stream chan Response, stop <-chan bool) (err
args = append(args, a...) args = append(args, a...)
} }
dirPath := os.Getenv("GOBIN") dirPath := os.Getenv("GOBIN")
if p.Tools.Run.Dir != "" { if p.Tools.Run.Path != "" {
dirPath, _ = filepath.Abs(p.Tools.Run.Dir) dirPath, _ = filepath.Abs(p.Tools.Run.Path)
} }
name := filepath.Base(path) name := filepath.Base(path)
if path == "." && p.Tools.Run.Dir == "" { if path == "." && p.Tools.Run.Path == "" {
name = filepath.Base(Wdir()) name = filepath.Base(Wdir())
} else if p.Tools.Run.Dir != "" { } else if p.Tools.Run.Path != "" {
name = filepath.Base(dirPath) name = filepath.Base(dirPath)
} }
path = filepath.Join(dirPath, name) path = filepath.Join(dirPath, name)
if p.Tools.Run.Method != "" { if p.Tools.Run.Method != "" {
path = p.Tools.Run.Method path = p.Tools.Run.Method
} }
if _, err := os.Stat(path); err == nil { if _, err := os.Stat(path); err == nil {
build = exec.Command(path, args...) build = exec.Command(path, args...)
@ -618,6 +619,9 @@ func (p *Project) run(path string, stream chan Response, stop <-chan bool) (err
if err != nil { if err != nil {
return err return err
} }
if p.Tools.Run.Dir != "" {
build.Dir = p.Tools.Run.Dir
}
if err := build.Start(); err != nil { if err := build.Start(); err != nil {
return err return err
} }

View File

@ -5,6 +5,7 @@ package realize
import ( import (
"bytes" "bytes"
"encoding/json" "encoding/json"
"errors"
"fmt" "fmt"
"github.com/labstack/echo" "github.com/labstack/echo"
"github.com/labstack/echo/middleware" "github.com/labstack/echo/middleware"
@ -14,7 +15,6 @@ import (
"os/exec" "os/exec"
"runtime" "runtime"
"strconv" "strconv"
"errors"
) )
// Dafault host and port // Dafault host and port

View File

@ -14,6 +14,7 @@ import (
type Tool struct { type Tool struct {
Args []string `yaml:"args,omitempty" json:"args,omitempty"` Args []string `yaml:"args,omitempty" json:"args,omitempty"`
Method string `yaml:"method,omitempty" json:"method,omitempty"` Method string `yaml:"method,omitempty" json:"method,omitempty"`
Path string `yaml:"path,omitempty" json:"dir,omitempty"`
Dir string `yaml:"dir,omitempty" json:"dir,omitempty"` //wdir of the command Dir string `yaml:"dir,omitempty" json:"dir,omitempty"` //wdir of the command
Status bool `yaml:"status,omitempty" json:"status,omitempty"` Status bool `yaml:"status,omitempty" json:"status,omitempty"`
Output bool `yaml:"output,omitempty" json:"output,omitempty"` Output bool `yaml:"output,omitempty" json:"output,omitempty"`