Skip to content

Commit

Permalink
feat: posttest and pretest scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcel Kloubert committed May 14, 2024
1 parent 46de0ae commit 05d7e6d
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 13 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
- feat: `execute` command which runs shell commands with the environment variables loaded from .env* files
- fix: exit app if special files could not be loaded
- feat: `run` command without scripts will run `go run .` now
- feat: `postbuild`, `postinstall`, `prebuild` and `preinstall` script support
- feat: `postbuild`, `postinstall`, `posttest`, `prebuild`, `preinstall` and `pretest` script support
- feat: add `--no-script` flags for `build`, `start`, `test` and `tidy`

## 0.10.1
Expand Down
19 changes: 10 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -443,15 +443,16 @@ From the project folder you will be able to execute `gpm run test1` or `gpm run

#### Predefined [<a href="#scripts-">↑</a>]

| Name | |
|---------------|-------------------------------------------------------------------------------------|
| `postbuild` | Is executed after successful execution of [build command](#build-project-) |
| `postinstall` | Is executed after successful execution of [install command](#install-dependencies-) |
| `prebuild` | Is executed before [build command](#build-project-) is executed |
| `preinstall` | Is executed before [install command](#install-dependencies-) is executed |
| `start` | Is executed by [start command](#start-project-) |
| `test` | Is executed by [test command](#run-tests-) |
| `tidy` | Is executed by [tidy command](#cleanup-project-) |
| Name | |
|---------------|---------------------------------------------------------------------------------------------|
| `postbuild` | Is executed after successful execution of [build command](#build-project-). |
| `postinstall` | Is executed after successful execution of [install command](#install-dependencies-). |
| `prebuild` | Is executed before [build command](#build-project-) is executed. |
| `preinstall` | Is executed before [install command](#install-dependencies-) is executed. |
| `pretest` | Is executed before [test command](#run-tests-) is executed. |
| `start` | Is executed by [start command](#start-project-). If not defined `go run .` is executed. |
| `test` | Is executed by [test command](#run-tests-). If not defined `go test .` is executed. |
| `tidy` | Is executed by [tidy command](#cleanup-project-). If not defined `go mod tidy` is executed. | |

## Contribution [<a href="#table-of-contents">↑</a>]

Expand Down
2 changes: 1 addition & 1 deletion commands/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func Init_Start_Command(parentCmd *cobra.Command, app *types.AppContext) {
},
}

parentCmd.Flags().BoolVarP(&noScript, "no-script", "n", false, "do not handle '"+startScriptName+"' script")
startCmd.Flags().BoolVarP(&noScript, "no-script", "n", false, "do not handle '"+startScriptName+"' script")

parentCmd.AddCommand(
startCmd,
Expand Down
8 changes: 7 additions & 1 deletion commands/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,13 @@ import (
"github.com/spf13/cobra"
)

const postTestScriptName = "posttest"
const preTestScriptName = "pretest"
const testScriptName = "test"

func Init_Test_Command(parentCmd *cobra.Command, app *types.AppContext) {
var noPostScript bool
var noPreScript bool
var noScript bool

var testCmd = &cobra.Command{
Expand All @@ -48,7 +52,9 @@ func Init_Test_Command(parentCmd *cobra.Command, app *types.AppContext) {
},
}

parentCmd.Flags().BoolVarP(&noScript, "no-script", "n", false, "do not handle '"+testScriptName+"' script")
testCmd.Flags().BoolVarP(&noPostScript, "no-post-script", "", false, "do not handle '"+postTestScriptName+"' script")
testCmd.Flags().BoolVarP(&noPreScript, "no-pre-script", "", false, "do not handle '"+preTestScriptName+"' script")
testCmd.Flags().BoolVarP(&noScript, "no-script", "n", false, "do not handle '"+testScriptName+"' script")

parentCmd.AddCommand(
testCmd,
Expand Down
2 changes: 1 addition & 1 deletion commands/tidy.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func Init_Tidy_Command(parentCmd *cobra.Command, app *types.AppContext) {
},
}

parentCmd.Flags().BoolVarP(&noScript, "no-script", "n", false, "do not handle '"+tidyScriptName+"' script")
tidyCmd.Flags().BoolVarP(&noScript, "no-script", "n", false, "do not handle '"+tidyScriptName+"' script")

parentCmd.AddCommand(
tidyCmd,
Expand Down

0 comments on commit 05d7e6d

Please sign in to comment.