Skip to content
This repository was archived by the owner on May 25, 2025. It is now read-only.

Commit bc40ff0

Browse files
fix(exec2): logStart/logEnd
1 parent ae9dcca commit bc40ff0

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/util/exec2.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ class Exec2 {
6262
forceColor = hasColors,
6363
} = opt
6464
opt.log ??= printWhileRunning // by default log should be true, as we are printing the output
65+
opt.logStart ??= opt.log
66+
opt.logFinish ??= opt.log
6567
const started = Date.now()
6668
this.logStart(cmd, opt)
6769
let stdout = ''
@@ -133,6 +135,8 @@ class Exec2 {
133135
spawn(cmd: string, opt: SpawnOptions = {}): void {
134136
const { shell = true, cwd, env, passProcessEnv = true, forceColor = hasColors } = opt
135137
opt.log ??= true // by default log should be true, as we are printing the output
138+
opt.logStart ??= opt.log
139+
opt.logFinish ??= opt.log
136140
const started = Date.now()
137141
this.logStart(cmd, opt)
138142
// console.log('') // 1-line padding before the output
@@ -173,12 +177,14 @@ class Exec2 {
173177
* Defaults:
174178
*
175179
* shell: true
176-
* log: true
180+
* log: false
177181
*/
178182
exec(cmd: string, opt: ExecOptions = {}): string {
183+
const { cwd, env, passProcessEnv = true, timeout } = opt
184+
opt.logStart ??= opt.log ?? false
185+
opt.logFinish ??= opt.log ?? false
179186
const started = Date.now()
180187
this.logStart(cmd, opt)
181-
const { cwd, env, passProcessEnv = true, timeout } = opt
182188

183189
try {
184190
const s = cp
@@ -219,7 +225,7 @@ class Exec2 {
219225
}
220226

221227
private logStart(cmd: string, opt: SpawnOptions | ExecOptions): void {
222-
if (!opt.logStart && !opt.log) return
228+
if (!opt.logStart) return
223229

224230
console.log(
225231
[
@@ -238,7 +244,7 @@ class Exec2 {
238244
started: UnixTimestampMillisNumber,
239245
isSuccessful: boolean,
240246
): void {
241-
if (isSuccessful && !opt.logFinish && !opt.log) return
247+
if (isSuccessful && !opt.logFinish) return
242248

243249
console.log(
244250
[

0 commit comments

Comments
 (0)