Skip to content

Commit

Permalink
Merge branch 'fix-import-exit-code'
Browse files Browse the repository at this point in the history
  • Loading branch information
cwarden committed Sep 5, 2023
2 parents 5faef9c + a50cdc1 commit aff1a85
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions command/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func deploy(force *Force, files ForceMetadataFiles, deployOptions *ForceDeployOp
return fmt.Errorf("Failed to generate output: %w", err)
}
fmt.Println(output)
if result.HasComponentFailures() || (result.HasTestFailures() && exitCodeOnTestFailure) || !result.Success {
if result.HasComponentFailures() || (result.HasTestFailures() && errorOnTestFailure) || !result.Success {
return fmt.Errorf("Deploy unsuccessful")
}
return nil
Expand Down Expand Up @@ -123,7 +123,7 @@ func deploy(force *Force, files ForceMetadataFiles, deployOptions *ForceDeployOp

if result.HasComponentFailures() {
err = errors.New("Some components failed deployment")
} else if result.HasTestFailures() && exitCodeOnTestFailure {
} else if result.HasTestFailures() && errorOnTestFailure {
err = errors.New("Some tests failed")
} else if !result.Success {
err = errors.New(fmt.Sprintf("Status: %s, Status Code: %s, Error Message: %s", result.Status, result.ErrorStatusCode, result.ErrorMessage))
Expand Down
6 changes: 3 additions & 3 deletions command/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func init() {

importCmd.Flags().StringP("directory", "d", "src", "relative path to package.xml")

importCmd.Flags().BoolVarP(&exitCodeOnTestFailure, "erroronfailure", "E", true, "exit with an error code if any tests fail")
importCmd.Flags().BoolVarP(&errorOnTestFailure, "erroronfailure", "E", true, "exit with an error code if any tests fail")

RootCmd.AddCommand(importCmd)
}
Expand All @@ -59,7 +59,7 @@ var importCmd = &cobra.Command{
}

var (
exitCodeOnTestFailure bool
errorOnTestFailure bool
)

func sourceDir(cmd *cobra.Command) string {
Expand Down Expand Up @@ -119,7 +119,7 @@ func runImport(root string, options ForceDeployOptions, displayOptions *deployOu
if err == nil && displayOptions.reportFormat == "text" && !displayOptions.quiet {
fmt.Printf("Imported from %s\n", root)
}
if err != nil && exitCodeOnTestFailure {
if err != nil {
ErrorAndExit(err.Error())
}
}

0 comments on commit aff1a85

Please sign in to comment.