Skip to content

Commit

Permalink
feature: Add LEFTHOOK_VERBOSE env (#346)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrexox authored Nov 1, 2022
1 parent 5221291 commit 8a22aad
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
5 changes: 5 additions & 0 deletions docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- [`LEFTHOOK`](#lefthook)
- [`LEFTHOOK_EXCLUDE`](#lefthook_exclude)
- [`LEFTHOOK_QUIET`](#lefthook_quiet)
- [`LEFTHOOK_VERBOSE`](#lefthook_verbose)
- [Features and tips](#features-and-tips)
- [Disable lefthook in CI](#disable-lefthook-in-ci)
- [Local config](#local-config)
Expand Down Expand Up @@ -163,6 +164,10 @@ SUMMARY: (done in 0.01 seconds)
🥊 lint
```

### `LEFTHOOK_VERBOSE`

Set `LEFTHOOK_VERBOSE=1` or `LEFTHOOK_VERBOSE=true` to enable verbose printing.

## Features and tips

### Disable lefthook in CI
Expand Down
13 changes: 9 additions & 4 deletions internal/lefthook/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ import (
)

const (
envEnabled = "LEFTHOOK" // "0", "false"
envSkipOutput = "LEFTHOOK_QUIET" // "meta,success,failure,summary,execution"
envEnabled = "LEFTHOOK" // "0", "false"
envSkipOutput = "LEFTHOOK_QUIET" // "meta,success,failure,summary,execution"
envVerbose = "LEFTHOOK_VERBOSE" // keep all output
)

func Run(opts *Options, hookName string, gitArgs []string) error {
Expand All @@ -32,8 +33,12 @@ func (l *Lefthook) Run(hookName string, gitArgs []string) error {
return nil
}

if hookName == config.GhostHookName {
log.SetLevel(log.WarnLevel)
if l.Verbose || os.Getenv(envVerbose) == "1" || os.Getenv(envVerbose) == "true" {
log.SetLevel(log.DebugLevel)
} else {
if hookName == config.GhostHookName {
log.SetLevel(log.WarnLevel)
}
}

// Load config
Expand Down

0 comments on commit 8a22aad

Please sign in to comment.