Skip to content

Commit

Permalink
expand home dir ("~" symbol) on paths
Browse files Browse the repository at this point in the history
fixes #74
  • Loading branch information
andreynering committed Nov 2, 2017
1 parent f4216dd commit baac067
Show file tree
Hide file tree
Showing 7 changed files with 196 additions and 5 deletions.
8 changes: 7 additions & 1 deletion Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,7 @@
[[constraint]]
branch = "master"
name = "github.com/radovskyb/watcher"

[[constraint]]
branch = "master"
name = "github.com/mitchellh/go-homedir"
5 changes: 5 additions & 0 deletions internal/status/glob.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,18 @@ import (
"sort"

"github.com/mattn/go-zglob"
"github.com/mitchellh/go-homedir"
)

func glob(dir string, globs []string) (files []string, err error) {
for _, g := range globs {
if !filepath.IsAbs(g) {
g = filepath.Join(dir, g)
}
g, err = homedir.Expand(g)
if err != nil {
return nil, err
}
f, err := zglob.Glob(g)
if err != nil {
return nil, err
Expand Down
12 changes: 8 additions & 4 deletions variables.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/go-task/task/internal/execext"

"github.com/Masterminds/sprig"
"github.com/mitchellh/go-homedir"
)

var (
Expand Down Expand Up @@ -202,12 +203,11 @@ func (e *Executor) CompiledTask(call Call) (*Task, error) {
return nil, &taskNotFoundError{call.Task}
}

var r varReplacer
if vars, err := e.getVariables(call); err == nil {
r.vars = vars
} else {
vars, err := e.getVariables(call)
if err != nil {
return nil, err
}
r := varReplacer{vars: vars}

new := Task{
Task: origTask.Task,
Expand All @@ -221,6 +221,10 @@ func (e *Executor) CompiledTask(call Call) (*Task, error) {
Silent: origTask.Silent,
Method: r.replace(origTask.Method),
}
new.Dir, err = homedir.Expand(new.Dir)
if err != nil {
return nil, err
}
if e.Dir != "" && !filepath.IsAbs(new.Dir) {
new.Dir = filepath.Join(e.Dir, new.Dir)
}
Expand Down
21 changes: 21 additions & 0 deletions vendor/github.com/mitchellh/go-homedir/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions vendor/github.com/mitchellh/go-homedir/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

137 changes: 137 additions & 0 deletions vendor/github.com/mitchellh/go-homedir/homedir.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit baac067

Please sign in to comment.