Skip to content

Commit

Permalink
More goreleaser fixes
Browse files Browse the repository at this point in the history
- Fix homebrew installs
- Search `env $PATH` in cause masonry executable cannot be found
  • Loading branch information
redhatrises committed Jun 21, 2018
1 parent e41d49e commit d14742c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,6 @@ brew:
commit_author:
name: OpenControl
email: [email protected]
description: Compliance Masonry is a command-line interface (CLI) that allows users to construct certification documentation using the OpenControl Schema.
homepage: https://github.com/opencontrol/compliance-masonry
install: bin.install "compliance-masonry", "masonry"
21 changes: 20 additions & 1 deletion cmd/compliance-masonry/compliance-masonry.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"os/exec"
"path/filepath"
"runtime"
"strings"
)

func main() {
Expand All @@ -23,12 +24,28 @@ func main() {
binary = "masonry"
}

envPaths := os.Getenv("PATH")
basepath := filepath.Dir(os.Args[0])
prog, err := filepath.Abs(filepath.Join(basepath, binary))
if err != nil {
log.Fatal(err)
}

if _, err := os.Stat(prog); os.IsNotExist(err) {
for _, envp := range strings.Split(envPaths, ":") {
cprog, err := filepath.Abs(filepath.Join(envp, binary))
if _, err := os.Stat(cprog); err == nil {
prog = filepath.Join(envp, binary)
}
if err != nil {
log.Fatal(err)
}
}
}
if err != nil {
log.Fatal(err)
}

args := os.Args
if len(args) > 1 {
cmd = exec.Command(prog, args[1:]...)
Expand All @@ -38,7 +55,9 @@ func main() {

output, err := cmd.CombinedOutput()
if err != nil {
//do nothing
if len(output) == 0 {
log.Fatal("Error: cannot find the 'masonry' executable")
}
}
fmt.Printf("%s\n", output)
}

0 comments on commit d14742c

Please sign in to comment.