Skip to content

Commit

Permalink
[skip travis] add HOOKAH=0 env for skip execution
Browse files Browse the repository at this point in the history
  • Loading branch information
A.A.Abroskin committed Mar 5, 2019
1 parent 406f4d2 commit 725ed17
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion cmd/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func addHook(hookName string, fs afero.Fs) {
# we suppose it in local npm package
if ! type hookah 2>/dev/null
then
exec npx hookah run ` + hookName + "\nelse\n exec hookah run " + hookName + "\nfi"
exec npx hookah run ` + hookName + " $@\nelse\n exec hookah run " + hookName + " $@\nfi\n"

pathToFile := filepath.Join(getGitHooksDir(), hookName)

Expand Down
16 changes: 10 additions & 6 deletions cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,11 @@ Example:

// RunCmdExecutor run executables in hook groups
func RunCmdExecutor(args []string, fs afero.Fs) error {
if os.Getenv("HOOKAH") == "0" {
return nil
}
hooksGroup := args[0]
gitArgs := args[1:]
var wg sync.WaitGroup

log.Println(aurora.Cyan("RUNNING HOOKS GROUP:"), aurora.Bold(hooksGroup))
Expand All @@ -86,9 +90,9 @@ func RunCmdExecutor(args []string, fs afero.Fs) error {
for _, executable := range executables {
wg.Add(1)
if getParallel(hooksGroup) {
go executeScript(hooksGroup, sourcePath, executable, &wg)
go executeScript(hooksGroup, sourcePath, executable, &wg, gitArgs)
} else {
executeScript(hooksGroup, sourcePath, executable, &wg)
executeScript(hooksGroup, sourcePath, executable, &wg, gitArgs)
}
}
}
Expand All @@ -99,9 +103,9 @@ func RunCmdExecutor(args []string, fs afero.Fs) error {
for _, executable := range executables {
wg.Add(1)
if getParallel(hooksGroup) {
go executeScript(hooksGroup, sourcePath, executable, &wg)
go executeScript(hooksGroup, sourcePath, executable, &wg, gitArgs)
} else {
executeScript(hooksGroup, sourcePath, executable, &wg)
executeScript(hooksGroup, sourcePath, executable, &wg, gitArgs)
}
}
}
Expand Down Expand Up @@ -186,7 +190,7 @@ func executeCommand(hooksGroup, commandName string, wg *sync.WaitGroup) {
mutex.Unlock()
}

func executeScript(hooksGroup, source string, executable os.FileInfo, wg *sync.WaitGroup) {
func executeScript(hooksGroup, source string, executable os.FileInfo, wg *sync.WaitGroup, gitArgs []string) {
defer wg.Done()
executableName := executable.Name()

Expand All @@ -207,7 +211,7 @@ func executeScript(hooksGroup, source string, executable os.FileInfo, wg *sync.W
makeExecutable(pathToExecutable)
}

command := exec.Command(pathToExecutable)
command := exec.Command(pathToExecutable, gitArgs[:]...)

if haveRunner(hooksGroup, scriptsConfigKey, executableName) {
runnerArg := strings.Split(getRunner(hooksGroup, scriptsConfigKey, executableName), " ")
Expand Down

0 comments on commit 725ed17

Please sign in to comment.