From ee548bf5f2cf7fc97fad77c710b27929b327833f Mon Sep 17 00:00:00 2001 From: "Eric J. Holmes" Date: Wed, 20 Sep 2017 20:33:45 -0700 Subject: [PATCH] Handle dependencies with absolute paths Fixes https://github.com/ejholmes/walk/issues/22 --- plan.go | 8 +++++++- test/110-compile/Walkfile | 3 ++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/plan.go b/plan.go index 050579a..1214fba 100644 --- a/plan.go +++ b/plan.go @@ -309,8 +309,14 @@ func (t *target) Dependencies(ctx context.Context) ([]string, error) { if path == "" { continue } + + // If the path is not already and absolute path, make it one. + if !filepath.IsAbs(path) { + path = filepath.Join(t.dir, path) + } + // Make all paths relative to the working directory. - path, err := filepath.Rel(t.wd, filepath.Join(t.dir, scanner.Text())) + path, err := filepath.Rel(t.wd, path) if err != nil { return deps, err } diff --git a/test/110-compile/Walkfile b/test/110-compile/Walkfile index e03848a..a5f3c5d 100755 --- a/test/110-compile/Walkfile +++ b/test/110-compile/Walkfile @@ -11,7 +11,8 @@ case $target in all) case $phase in deps) - echo hello + # Absolute paths work too. + echo $PWD/hello echo test ;; esac ;;