Skip to content

Commit ab89c7f

Browse files
authored
chore: skip summary separator if nothing is printed (#575)
1 parent d527c1f commit ab89c7f

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

internal/lefthook/lefthook.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ import (
1515
)
1616

1717
const (
18-
hookFileMode = 0o755
19-
envVerbose = "LEFTHOOK_VERBOSE" // keep all output
18+
hookFileMode = 0o755
19+
envVerbose = "LEFTHOOK_VERBOSE" // keep all output
20+
oldHookPostfix = ".old"
2021
)
2122

2223
var lefthookContentRegexp = regexp.MustCompile("LEFTHOOK")
@@ -94,7 +95,7 @@ func (l *Lefthook) cleanHook(hook string, force bool) error {
9495
}
9596

9697
// Check if .old file already exists before renaming.
97-
exists, err = afero.Exists(l.Fs, hookPath+".old")
98+
exists, err = afero.Exists(l.Fs, hookPath+oldHookPostfix)
9899
if err != nil {
99100
return err
100101
}
@@ -107,7 +108,7 @@ func (l *Lefthook) cleanHook(hook string, force bool) error {
107108
}
108109
}
109110

110-
err = l.Fs.Rename(hookPath, hookPath+".old")
111+
err = l.Fs.Rename(hookPath, hookPath+oldHookPostfix)
111112
if err != nil {
112113
return err
113114
}

internal/lefthook/run.go

+8-2
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,15 @@ func printSummary(
181181
results []run.Result,
182182
logSettings log.SkipSettings,
183183
) {
184+
summaryPrint := log.Separate
185+
186+
if logSettings.SkipExecution() || (logSettings.SkipExecutionInfo() && logSettings.SkipExecutionOutput()) {
187+
summaryPrint = func(s string) { log.Info(s) }
188+
}
189+
184190
if len(results) == 0 {
185191
if !logSettings.SkipEmptySummary() {
186-
log.Separate(
192+
summaryPrint(
187193
fmt.Sprintf(
188194
"%s %s %s",
189195
log.Cyan("summary:"),
@@ -195,7 +201,7 @@ func printSummary(
195201
return
196202
}
197203

198-
log.Separate(
204+
summaryPrint(
199205
log.Cyan("summary: ") + log.Gray(fmt.Sprintf("(done in %.2f seconds)", duration.Seconds())),
200206
)
201207

0 commit comments

Comments
 (0)