Skip to content

Commit

Permalink
handle non-go directories better
Browse files Browse the repository at this point in the history
  • Loading branch information
markbates committed Nov 30, 2019
1 parent f233917 commit 2535a34
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
8 changes: 3 additions & 5 deletions cmd/here/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"os"
"os/exec"

"github.com/gobuffalo/here"
"github.com/gobuffalo/here/there"
)

func main() {
Expand All @@ -21,12 +21,10 @@ func main() {
args = append(args, pwd)
}

h := here.New()

fn := h.Dir
fn := there.Dir
switch args[0] {
case "pkg":
fn = h.Package
fn = there.Package
args = args[1:]
if len(args) == 0 {
log.Fatalf("you must pass at least one package name")
Expand Down
3 changes: 3 additions & 0 deletions dir.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ func fromNonGoDir(dir string) (Info, error) {

b, err := run("go", "list", "-json", "-m")
if err != nil {
if nonGoDirRx.MatchString(err.Error()) {
return i, nil
}
return i, err
}

Expand Down
2 changes: 1 addition & 1 deletion here.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ func (h Here) cache(p string, fn func(string) (Info, error)) (Info, error) {
return i, nil
}

var nonGoDirRx = regexp.MustCompile(`cannot find main|go help modules|go: |build .:|no Go files|can't load package`)
var nonGoDirRx = regexp.MustCompile(`cannot find main|go help modules|go: |build .:|no Go files|can't load package|not using modules`)

0 comments on commit 2535a34

Please sign in to comment.