Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions task.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ type Task struct {
Deps []string
Sources []string
Generates []string
Dir string
}

type taskNotFoundError struct {
Expand Down Expand Up @@ -100,7 +101,7 @@ func RunTask(name string) error {
}

for _, c := range t.Cmds {
if err := runCommand(c); err != nil {
if err := runCommand(c, t.Dir); err != nil {
return &taskRunError{name, err}
}
}
Expand All @@ -125,13 +126,16 @@ func isTaskUpToDate(t *Task) bool {
return generatesMinTime.After(sourcesMaxTime)
}

func runCommand(c string) error {
func runCommand(c, path string) error {
var cmd *exec.Cmd
if ShExists {
cmd = exec.Command(ShPath, "-c", c)
} else {
cmd = exec.Command("cmd", "/C", c)
}
if path != "" {
cmd.Dir = path
}
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
if err := cmd.Run(); err != nil {
Expand Down