Skip to content

Commit

Permalink
Add ability to skip summary output. Also support a LEFT_QUIET environ…
Browse files Browse the repository at this point in the history
…ment variable.
  • Loading branch information
washtubs committed May 15, 2021
1 parent e0d4765 commit ae53d40
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
12 changes: 12 additions & 0 deletions cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ const (
parallelConfigKey string = "parallel"
skipOutputConfigKey string = "skip_output"
outputMeta string = "meta"
outputSummary string = "summary"
outputSuccess string = "success"
subFiles string = "{files}"
subAllFiles string = "{all_files}"
Expand Down Expand Up @@ -418,6 +419,10 @@ func printMeta(hooksGroup string) {
}

func printSummary(execTime time.Duration) {
if isSkipPrintOutput(outputSummary) {
return
}

if len(okList) == 0 && len(failList) == 0 {
log.Println(au.Cyan("\nSUMMARY:"), au.Brown("(SKIP EMPTY)"))
} else {
Expand Down Expand Up @@ -470,6 +475,13 @@ func isSkipPrintOutput(outputDetailValue string) bool {
}
}

env := os.Getenv("LEFTHOOK_QUIET")
for _, elem := range strings.Split(env, ",") {
if strings.TrimSpace(elem) == outputDetailValue {
return true
}
}

return false
}

Expand Down
24 changes: 23 additions & 1 deletion docs/full_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ If you need to extend config from some another place, just add top level:
```yml
# lefthook.yml
extends:
extends:
- $HOME/work/lefthook-extend.yml
- $HOME/work/lefthook-extend-2.yml
```
Expand Down Expand Up @@ -469,6 +469,28 @@ source_dir: ".lefthook"
source_dir_local: ".lefthook-local"
```

## Mange verbosity

You can manage the verbosity using the `skip_output` config.

Possible values are `meta,success,failure,summary`.

This config quiets all outputs except failures:

```yml
# lefthook.yml
skip_output:
- meta
- success
- summary
```

You can also do this with an environment variable:
```bash
export LEFTHOOK_QUIET="meta,success,summary"
```

## CI integration

Enable `CI` env variable if it doens't exists on your service by default.
Expand Down

0 comments on commit ae53d40

Please sign in to comment.