diff --git a/cmd/run.go b/cmd/run.go index b45f70c1..681d8d9f 100644 --- a/cmd/run.go +++ b/cmd/run.go @@ -170,8 +170,9 @@ func executeCommand(hooksGroup, commandName string, wg *sync.WaitGroup) { defer wg.Done() if getPiped(hooksGroup) && isPipeBroken { - log.Println(au.Cyan("\n EXECUTE >"), au.Bold(commandName)) - log.Println(au.Brown("(SKIP BY BROKEN PIPE)")) + mutex.Lock() + log.Println("\n", au.Bold(commandName), au.Brown("(SKIP BY BROKEN PIPE)")) + mutex.Unlock() return } @@ -210,22 +211,28 @@ func executeCommand(hooksGroup, commandName string, wg *sync.WaitGroup) { runner = strings.Replace(runner, subAllFiles, strings.Join(files, " "), -1) runner = strings.Replace(runner, subFiles, strings.Join(files, " "), -1) + command := exec.Command("sh", "-c", runner) + command.Stdin = os.Stdin + if isSkipCommmand(hooksGroup, commandName) { - log.Println(au.Bold(commandName), au.Brown("(SKIP BY SETTINGS)")) + mutex.Lock() + log.Println("\n", au.Bold(commandName), au.Brown("(SKIP BY SETTINGS)")) + mutex.Unlock() return } if result, _ := arrop.Intersect(getExcludeTags(hooksGroup), getTags(hooksGroup, commandsConfigKey, commandName)); len(result.Interface().([]string)) > 0 { - log.Println(au.Bold(commandName), au.Brown("(SKIP BY TAGS)")) + mutex.Lock() + log.Println("\n", au.Bold(commandName), au.Brown("(SKIP BY TAGS)")) + mutex.Unlock() return } if len(files) < 1 && isSkipEmptyCommmand(hooksGroup, commandName) { - log.Println(au.Bold(commandName), au.Brown("(SKIP. NO FILES FOR INSPECTING)")) + mutex.Lock() + log.Println("\n", au.Bold(commandName), au.Brown("(SKIP. NO FILES FOR INSPECTING)")) + mutex.Unlock() return } - command := exec.Command("sh", "-c", runner) - command.Stdin = os.Stdin - ptyOut, err := pty.Start(command) mutex.Lock() defer mutex.Unlock() @@ -258,8 +265,9 @@ func executeScript(hooksGroup, source string, executable os.FileInfo, wg *sync.W executableName := executable.Name() if getPiped(hooksGroup) && isPipeBroken { - log.Println(au.Cyan("\n EXECUTE >"), au.Bold(executableName)) - log.Println(au.Brown("(SKIP BY BROKEN PIPE)")) + mutex.Lock() + log.Println("\n", au.Bold(executableName), au.Brown("(SKIP BY BROKEN PIPE)")) + mutex.Unlock() return } @@ -282,15 +290,21 @@ func executeScript(hooksGroup, source string, executable os.FileInfo, wg *sync.W } if !isScriptExist(hooksGroup, executableName) { - log.Println(au.Bold(executableName), au.Brown("(SKIP BY NOT EXIST IN CONFIG)")) + mutex.Lock() + log.Println("\n", au.Bold(executableName), au.Brown("(SKIP BY NOT EXIST IN CONFIG)")) + mutex.Unlock() return } if isSkipScript(hooksGroup, executableName) { - log.Println(au.Bold(executableName), au.Brown("(SKIP BY SETTINGS)")) + mutex.Lock() + log.Println("\n", au.Bold(executableName), au.Brown("(SKIP BY SETTINGS)")) + mutex.Unlock() return } if result, _ := arrop.Intersect(getExcludeTags(hooksGroup), getTags(hooksGroup, scriptsConfigKey, executableName)); len(result.Interface().([]string)) > 0 { - log.Println(au.Bold(executableName), au.Brown("(SKIP BY TAGS)")) + mutex.Lock() + log.Println("\n", au.Bold(executableName), au.Brown("(SKIP BY TAGS)")) + mutex.Unlock() return } diff --git a/cmd/run_windows.go b/cmd/run_windows.go index 72d55220..6d0eb564 100644 --- a/cmd/run_windows.go +++ b/cmd/run_windows.go @@ -165,8 +165,9 @@ func executeCommand(hooksGroup, commandName string, wg *sync.WaitGroup) { defer wg.Done() if getPiped(hooksGroup) && isPipeBroken { - log.Println(au.Cyan("\n EXECUTE >"), au.Bold(commandName)) - log.Println(au.Brown("(SKIP BY BROKEN PIPE)")) + mutex.Lock() + log.Println("\n", au.Bold(commandName), au.Brown("(SKIP BY BROKEN PIPE)")) + mutex.Unlock() return } @@ -206,15 +207,21 @@ func executeCommand(hooksGroup, commandName string, wg *sync.WaitGroup) { runner = strings.Replace(runner, subFiles, strings.Join(files, " "), -1) if isSkipCommmand(hooksGroup, commandName) { - log.Println(au.Bold(commandName), au.Brown("(SKIP BY SETTINGS)")) + mutex.Lock() + log.Println("\n", au.Bold(commandName), au.Brown("(SKIP BY SETTINGS)")) + mutex.Unlock() return } if result, _ := arrop.Intersect(getExcludeTags(hooksGroup), getTags(hooksGroup, commandsConfigKey, commandName)); len(result.Interface().([]string)) > 0 { - log.Println(au.Bold(commandName), au.Brown("(SKIP BY TAGS)")) + mutex.Lock() + log.Println("\n", au.Bold(commandName), au.Brown("(SKIP BY TAGS)")) + mutex.Unlock() return } if len(files) < 1 && isSkipEmptyCommmand(hooksGroup, commandName) { - log.Println(au.Bold(commandName), au.Brown("(SKIP. NO FILES FOR INSPECTING)")) + mutex.Lock() + log.Println("\n", au.Bold(commandName), au.Brown("(SKIP. NO FILES FOR INSPECTING)")) + mutex.Unlock() return } @@ -250,8 +257,9 @@ func executeScript(hooksGroup, source string, executable os.FileInfo, wg *sync.W executableName := executable.Name() if getPiped(hooksGroup) && isPipeBroken { - log.Println(au.Cyan("\n EXECUTE >"), au.Bold(executableName)) - log.Println(au.Brown("(SKIP BY BROKEN PIPE)")) + mutex.Lock() + log.Println("\n", au.Bold(executableName), au.Brown("(SKIP BY BROKEN PIPE)")) + mutex.Unlock() return } @@ -277,15 +285,21 @@ func executeScript(hooksGroup, source string, executable os.FileInfo, wg *sync.W command.Stderr = os.Stderr // win specific if !isScriptExist(hooksGroup, executableName) { - log.Println(au.Bold(executableName), au.Brown("(SKIP BY NOT EXIST IN CONFIG)")) + mutex.Lock() + log.Println("\n", au.Bold(executableName), au.Brown("(SKIP BY NOT EXIST IN CONFIG)")) + mutex.Unlock() return } if isSkipScript(hooksGroup, executableName) { - log.Println(au.Bold(executableName), au.Brown("(SKIP BY SETTINGS)")) + mutex.Lock() + log.Println("\n", au.Bold(executableName), au.Brown("(SKIP BY SETTINGS)")) + mutex.Unlock() return } if result, _ := arrop.Intersect(getExcludeTags(hooksGroup), getTags(hooksGroup, scriptsConfigKey, executableName)); len(result.Interface().([]string)) > 0 { - log.Println(au.Bold(executableName), au.Brown("(SKIP BY TAGS)")) + mutex.Lock() + log.Println("\n", au.Bold(executableName), au.Brown("(SKIP BY TAGS)")) + mutex.Unlock() return }