Skip to content

Commit

Permalink
add timings
Browse files Browse the repository at this point in the history
  • Loading branch information
A.A.Abroskin committed Apr 17, 2019
1 parent a7c8784 commit afcf135
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ package cmd

import (
"errors"
"fmt"
"log"
"os"
"os/exec"
"path/filepath"
"regexp"
"strings"
"sync"
"time"

"github.com/Arkweid/lefthook/context"

Expand Down Expand Up @@ -88,6 +90,7 @@ func RunCmdExecutor(args []string, fs afero.Fs) error {
gitArgs := args[1:]
var wg sync.WaitGroup

startTime := time.Now()
log.Println(aurora.Cyan("RUNNING HOOKS GROUP:"), aurora.Bold(hooksGroup))

sourcePath := filepath.Join(getSourceDir(), hooksGroup)
Expand Down Expand Up @@ -131,7 +134,7 @@ func RunCmdExecutor(args []string, fs afero.Fs) error {

wg.Wait()

printSummary()
printSummary(time.Now().Sub(startTime))

if len(failList) == 0 {
return nil
Expand Down Expand Up @@ -276,19 +279,19 @@ func getRunner(hooksGroup, source, executableName string) string {
return runner
}

func printSummary() {
func printSummary(execTime time.Duration) {
if len(okList) == 0 && len(failList) == 0 {
log.Println(aurora.Cyan("\nSUMMARY:"), aurora.Brown("(SKIP EMPTY)"))
} else {
log.Println(aurora.Cyan("\nSUMMARY:"))
log.Println(aurora.Cyan(fmt.Sprintf("\nSUMMARY: (done in %.2f seconds)", execTime.Seconds())))
}

for _, fileName := range okList {
log.Printf("[ %s ] %s\n", aurora.Green("OK"), fileName)
log.Printf("✔️ %s\n", aurora.Green(fileName))
}

for _, fileName := range failList {
log.Printf("[ %s ] %s\n", aurora.Red("FAIL"), fileName)
log.Printf("🥊 %s", aurora.Red(fileName))
}
}

Expand Down

0 comments on commit afcf135

Please sign in to comment.