@@ -12,6 +12,7 @@ import {
12
12
text as promptText ,
13
13
} from '@clack/prompts' ;
14
14
import color from 'picocolors' ;
15
+ import { progress } from './progress' ;
15
16
import {
16
17
ConfirmPromptArgs ,
17
18
MultiselectPromptArgs ,
@@ -22,31 +23,44 @@ import {
22
23
import { listenForKeys } from './utils/waitInputToContinue' ;
23
24
24
25
export function log ( msg : string ) : void {
26
+ if ( progress . isActive ) return ;
25
27
promptLog . step ( msg ) ;
26
28
}
27
29
28
30
export function logSuccess ( msg : string ) : void {
31
+ const isProgressActive = progress . isActive ;
32
+ if ( isProgressActive ) progress . hide ( ) ;
29
33
promptLog . success ( msg ) ;
34
+ if ( isProgressActive ) progress . display ( ) ;
30
35
}
31
36
32
37
export function logMessage ( msg : string ) : void {
38
+ if ( progress . isActive ) return ;
33
39
promptLog . message ( '⦿ ' + msg ) ;
34
40
}
35
41
36
42
export function logMessageGray ( msg : string ) : void {
43
+ if ( progress . isActive ) return ;
37
44
promptLog . message ( color . gray ( '⦿ ' + msg ) ) ;
38
45
}
39
46
40
47
export function logWarning ( msg : string , noColor ?: boolean ) : void {
48
+ const isProgressActive = progress . isActive ;
49
+ if ( isProgressActive ) progress . hide ( ) ;
41
50
promptLog . warning ( noColor ? msg : color . yellow ( msg ) ) ;
51
+ if ( isProgressActive ) progress . display ( ) ;
42
52
}
43
53
44
54
export function logInfo ( msg : string ) : void {
55
+ if ( progress . isActive ) return ;
45
56
promptLog . info ( msg ) ;
46
57
}
47
58
48
59
export function logError ( msg : string , noColor ?: boolean ) : void {
60
+ const isProgressActive = progress . isActive ;
61
+ if ( isProgressActive ) progress . hide ( ) ;
49
62
promptLog . error ( noColor ? msg : color . red ( msg ) ) ;
63
+ if ( isProgressActive ) progress . display ( ) ;
50
64
}
51
65
52
66
export function logNote ( msg : string , title ?: string ) : void {
@@ -68,15 +82,18 @@ export function startSpinner(
68
82
msg : string ,
69
83
onCancel ?: ( key : string ) => void
70
84
) : void {
85
+ if ( progress . isActive ) return ;
71
86
s . start ( msg ) ;
72
87
if ( onCancel ) releaseListener = listenForKeys ( 's' , onCancel ) ;
73
88
}
74
89
75
90
export function updateSpinner ( msg : string ) : void {
91
+ if ( progress . isActive ) return ;
76
92
s . message ( msg ) ;
77
93
}
78
94
79
95
export function stopSpinner ( msg : string ) : void {
96
+ if ( progress . isActive ) return ;
80
97
s . stop ( msg ) ;
81
98
if ( releaseListener ) {
82
99
releaseListener ( ) ;
@@ -88,6 +105,8 @@ export async function multiselect(
88
105
msg : string ,
89
106
args : MultiselectPromptArgs
90
107
) : Promise < OptionValue [ ] > {
108
+ const isProgressActive = progress . isActive ;
109
+ if ( isProgressActive ) progress . hide ( ) ;
91
110
const response = await promptMultiselect ( {
92
111
message : msg ,
93
112
required : args . required ,
@@ -102,6 +121,7 @@ export async function multiselect(
102
121
cancel ( 'operation cancelled' ) ;
103
122
process . abort ( ) ;
104
123
}
124
+ if ( isProgressActive ) progress . display ( ) ;
105
125
// @ts -ignore
106
126
return response ;
107
127
}
@@ -110,6 +130,8 @@ export async function select(
110
130
msg : string ,
111
131
args : SelectPromptArgs
112
132
) : Promise < OptionValue > {
133
+ const isProgressActive = progress . isActive ;
134
+ if ( isProgressActive ) progress . hide ( ) ;
113
135
const response = await promptSelect ( {
114
136
message : msg ,
115
137
options : args . options . map ( x => ( {
@@ -124,6 +146,7 @@ export async function select(
124
146
cancel ( 'operation cancelled' ) ;
125
147
process . abort ( ) ;
126
148
}
149
+ if ( isProgressActive ) progress . display ( ) ;
127
150
// @ts -ignore
128
151
return response ;
129
152
}
@@ -132,6 +155,8 @@ export async function confirm(
132
155
msg : string ,
133
156
args : ConfirmPromptArgs = { }
134
157
) : Promise < boolean > {
158
+ const isProgressActive = progress . isActive ;
159
+ if ( isProgressActive ) progress . hide ( ) ;
135
160
const response = await promptConfirm ( {
136
161
message : msg ,
137
162
active : args . positive || 'yes' ,
@@ -142,13 +167,16 @@ export async function confirm(
142
167
cancel ( 'operation cancelled' ) ;
143
168
process . abort ( ) ;
144
169
}
170
+ if ( isProgressActive ) progress . display ( ) ;
145
171
return response ;
146
172
}
147
173
148
174
export async function text (
149
175
msg : string ,
150
176
args : TextPromptArgs = { }
151
177
) : Promise < string > {
178
+ const isProgressActive = progress . isActive ;
179
+ if ( isProgressActive ) progress . hide ( ) ;
152
180
const response = await promptText ( {
153
181
message : msg ,
154
182
defaultValue : args . defaultValue ,
@@ -160,6 +188,7 @@ export async function text(
160
188
cancel ( 'operation cancelled' ) ;
161
189
process . abort ( ) ;
162
190
}
191
+ if ( isProgressActive ) progress . display ( ) ;
163
192
return response ;
164
193
}
165
194
0 commit comments