From 06ef66b020876ff63f35d3ed628fa74064f038ab Mon Sep 17 00:00:00 2001 From: mdouchement Date: Fri, 17 May 2019 19:14:37 +0000 Subject: [PATCH] Add support of several GOPATH (#35) --- cmd/grifter.go | 5 +++-- go.mod | 8 +++++--- go.sum | 10 ++++++++++ 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/cmd/grifter.go b/cmd/grifter.go index e42410d..3776d5f 100644 --- a/cmd/grifter.go +++ b/cmd/grifter.go @@ -53,7 +53,8 @@ func newGrifter(name string) (*grifter, error) { return g, errors.WithStack(err) } - if strings.HasPrefix(currentPath, os.Getenv("GOPATH")) { + if envy.InGoPath() { + // pwd is inside a GOPATH for !strings.HasSuffix(currentPath, "/src") && currentPath != "/" { if hasGriftDir(currentPath) { break @@ -68,7 +69,7 @@ func newGrifter(name string) (*grifter, error) { g.GriftsAbsolutePath = filepath.ToSlash(filepath.Join(currentPath, "grifts")) g.GriftsPackagePath = filepath.ToSlash(filepath.Join(p[1], "grifts")) } else { - //is outside of gopath, dont loop to parent + // is outside of gopath, dont loop to parent if !hasGriftDir(currentPath) { return g, errors.Errorf("There is no directory named 'grifts'. Run '%s init' or switch to the appropriate directory", name) } diff --git a/go.mod b/go.mod index 1785fa8..f265634 100644 --- a/go.mod +++ b/go.mod @@ -1,8 +1,10 @@ module github.com/markbates/grift require ( - github.com/gobuffalo/envy v1.6.6 + github.com/gobuffalo/envy v1.7.0 + github.com/kr/pty v1.1.4 // indirect github.com/pkg/errors v0.8.0 - github.com/rogpeppe/go-internal v1.0.0 - github.com/stretchr/testify v1.2.2 + github.com/rogpeppe/go-internal v1.3.0 + github.com/stretchr/objx v0.2.0 // indirect + github.com/stretchr/testify v1.3.0 ) diff --git a/go.sum b/go.sum index 6f0a24a..f692f1c 100644 --- a/go.sum +++ b/go.sum @@ -1,11 +1,15 @@ +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/gobuffalo/envy v1.6.6 h1:QTIrr8kp0NBhJsjwP04jSnuXB2u6QDJVwESVuFiQWUY= github.com/gobuffalo/envy v1.6.6/go.mod h1:N+GkhhZ/93bGZc6ZKhJLP6+m+tCNPKwgSpH9kaifseQ= +github.com/gobuffalo/envy v1.7.0 h1:GlXgaiBkmrYMHco6t4j7SacKO4XUjvh5pwXh0f4uxXU= +github.com/gobuffalo/envy v1.7.0/go.mod h1:n7DRkBerg/aorDM8kbduw5dN3oXGswK5liaSCx4T5NI= github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc= github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/pty v1.1.4/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/pkg/errors v0.8.0 h1:WdK/asTD0HN+q6hsWO3/vpuAkAr+tw6aNJNDFFf0+qw= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -13,7 +17,13 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/rogpeppe/go-internal v1.0.0 h1:o4VLZ5jqHE+HahLT6drNtSGTrrUA3wPBmtpgqtdbClo= github.com/rogpeppe/go-internal v1.0.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/rogpeppe/go-internal v1.1.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/rogpeppe/go-internal v1.3.0 h1:RR9dF3JtopPvtkroDZuVD7qquD0bnHlKSqaQhgwt8yk= +github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=