Skip to content

Commit

Permalink
fix: Return proper exit code. Fixes #54
Browse files Browse the repository at this point in the history
  • Loading branch information
aalmiray committed Dec 15, 2023
1 parent efe0333 commit 2bc56ef
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 33 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: '1.20.4'
go-version: '1.21.5'

- name: Import GPG key
- name: Irt GPG key
id: import_gpg
uses: crazy-max/ghaction-import-gpg@v5
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: '1.20.4'
go-version: '1.21.5'

- name: Import GPG key
id: import_gpg
Expand Down
13 changes: 9 additions & 4 deletions gum/ant.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ type AntCommand struct {
}

// Execute executes the given command
func (c AntCommand) Execute() {
func (c AntCommand) Execute() int {
c.doConfigureAnt()
c.doExecuteAnt()
return c.doExecuteAnt()
}

func (c *AntCommand) doConfigureAnt() {
Expand Down Expand Up @@ -79,11 +79,16 @@ func (c *AntCommand) doConfigureAnt() {
}
}

func (c *AntCommand) doExecuteAnt() {
func (c *AntCommand) doExecuteAnt() int {
cmd := exec.Command(c.executable, c.args.Args...)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
cmd.Run()
err := cmd.Run()
var exerr *exec.ExitError
if errors.As(err, &exerr) {
return exerr.ExitCode()
}
return 0
}

func (c *AntCommand) debugConfig() {
Expand Down
13 changes: 9 additions & 4 deletions gum/bach.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ type BachCommand struct {
}

// Execute executes the given command
func (c BachCommand) Execute() {
func (c BachCommand) Execute() int {
c.doConfigureBach()
c.doExecuteBach()
return c.doExecuteBach()
}

func (c *BachCommand) doConfigureBach() {
Expand Down Expand Up @@ -70,11 +70,16 @@ func (c *BachCommand) doConfigureBach() {
}
}

func (c *BachCommand) doExecuteBach() {
func (c *BachCommand) doExecuteBach() int {
cmd := exec.Command(c.executable, c.args.Args...)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
cmd.Run()
err := cmd.Run()
var exerr *exec.ExitError
if errors.As(err, &exerr) {
return exerr.ExitCode()
}
return 0
}

func (c *BachCommand) debugConfig() {
Expand Down
13 changes: 9 additions & 4 deletions gum/gradle.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ type GradleCommand struct {
}

// Execute executes the given command
func (c GradleCommand) Execute() {
func (c GradleCommand) Execute() int {
c.doConfigureGradle()
c.doExecuteGradle()
return c.doExecuteGradle()
}

func (c *GradleCommand) doConfigureGradle() {
Expand Down Expand Up @@ -118,11 +118,16 @@ func (c *GradleCommand) doConfigureGradle() {
}
}

func (c *GradleCommand) doExecuteGradle() {
func (c *GradleCommand) doExecuteGradle() int {
cmd := exec.Command(c.executable, c.args.Args...)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
cmd.Run()
err := cmd.Run()
var exerr *exec.ExitError
if errors.As(err, &exerr) {
return exerr.ExitCode()
}
return 0
}

func (c *GradleCommand) debugConfig() {
Expand Down
13 changes: 9 additions & 4 deletions gum/jbang.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ type JbangCommand struct {
}

// Execute executes the given command
func (c JbangCommand) Execute() {
func (c JbangCommand) Execute() int {
c.doConfigureJbang()
c.doExecuteJbang()
return c.doExecuteJbang()
}

func (c *JbangCommand) doConfigureJbang() {
Expand Down Expand Up @@ -87,11 +87,16 @@ func (c *JbangCommand) doConfigureJbang() {
}
}

func (c *JbangCommand) doExecuteJbang() {
func (c *JbangCommand) doExecuteJbang() int {
cmd := exec.Command(c.executable, c.args.Args...)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
cmd.Run()
err := cmd.Run()
var exerr *exec.ExitError
if errors.As(err, &exerr) {
return exerr.ExitCode()
}
return 0
}

func (c *JbangCommand) debugConfig() {
Expand Down
13 changes: 9 additions & 4 deletions gum/maven.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ type MavenCommand struct {
}

// Execute executes the given command
func (c MavenCommand) Execute() {
func (c MavenCommand) Execute() int {
c.doConfigureMaven()
c.doExecuteMaven()
return c.doExecuteMaven()
}

func (c *MavenCommand) doConfigureMaven() {
Expand Down Expand Up @@ -88,11 +88,16 @@ func (c *MavenCommand) doConfigureMaven() {
}
}

func (c *MavenCommand) doExecuteMaven() {
func (c *MavenCommand) doExecuteMaven() int {
cmd := exec.Command(c.executable, c.args.Args...)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
cmd.Run()
err := cmd.Run()
var exerr *exec.ExitError
if errors.As(err, &exerr) {
return exerr.ExitCode()
}
return 0
}

func (c *MavenCommand) debugConfig() {
Expand Down
15 changes: 5 additions & 10 deletions gum/tool.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,39 +77,34 @@ func discoverTool(config *Config, context Context, args *ParsedArgs) {
func doFindGradle(context Context, args *ParsedArgs) {
gradle := FindGradle(context, args)
if gradle != nil {
gradle.Execute()
os.Exit(0)
os.Exit(gradle.Execute())
}
}

func doFindMaven(context Context, args *ParsedArgs) {
maven := FindMaven(context, args)
if maven != nil {
maven.Execute()
os.Exit(0)
os.Exit(maven.Execute())
}
}

func doFindJbang(context Context, args *ParsedArgs) {
jbang := FindJbang(context, args)
if jbang != nil {
jbang.Execute()
os.Exit(0)
os.Exit(jbang.Execute())
}
}

func doFindBach(context Context, args *ParsedArgs) {
bach := FindBach(context, args)
if bach != nil {
bach.Execute()
os.Exit(0)
os.Exit(bach.Execute())
}
}

func doFindAnt(context Context, args *ParsedArgs) {
ant := FindAnt(context, args)
if ant != nil {
ant.Execute()
os.Exit(0)
os.Exit(ant.Execute())
}
}

0 comments on commit 2bc56ef

Please sign in to comment.