Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to skip summary output. Also support a LEFTHOOK_QUIET env variable #187

Merged
merged 2 commits into from
May 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
```

## Manage 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