File tree 1 file changed +20
-21
lines changed
1 file changed +20
-21
lines changed Original file line number Diff line number Diff line change @@ -107,31 +107,32 @@ async function doPrompts() {
107
107
let targetDir = values [ 'project-name' ] || defaultProjectName ;
108
108
109
109
try {
110
- const { projectName } = await p . group (
110
+ const results = await p . group (
111
111
{
112
112
projectName : ( ) =>
113
113
p . text ( {
114
114
defaultValue : targetDir ,
115
115
message : 'Project Name' ,
116
116
placeholder : defaultProjectName ,
117
117
} ) ,
118
- } ,
119
- { onCancel } ,
120
- ) ;
121
- targetDir =
122
- typeof projectName === 'string' ? projectName . trim ( ) : targetDir ;
123
- if ( ! canSafelyOverwrite ( targetDir ) ) {
124
- const confirmed = await p . confirm ( {
125
- message : `${ targetDir } is not empty. Remove existing files and continue?` ,
126
- } ) ;
127
- if ( ! confirmed ) {
128
- p . cancel ( red ( '✖' ) + ' Operation cancelled' ) ;
129
- process . exit ( 0 ) ;
130
- }
131
- }
132
-
133
- const results = await p . group (
134
- {
118
+ overwrites : ( { results } ) => {
119
+ targetDir =
120
+ typeof results . projectName === 'string'
121
+ ? results . projectName . trim ( )
122
+ : targetDir ;
123
+ if ( ! canSafelyOverwrite ( targetDir ) ) {
124
+ return p . confirm ( {
125
+ message : `would you like to overwrite ${ results . projectName } ?` ,
126
+ } ) ;
127
+ }
128
+ return Promise . resolve ( true ) ;
129
+ } ,
130
+ checkOverwrites : ( { results } ) => {
131
+ if ( ! results . overwrites ) {
132
+ p . cancel ( red ( '✖' ) + ' Operation cancelled' ) ;
133
+ }
134
+ return Promise . resolve ( true ) ;
135
+ } ,
135
136
packageName : ( ) =>
136
137
p . text ( {
137
138
message : 'Package name' ,
@@ -150,9 +151,7 @@ async function doPrompts() {
150
151
} ) ) ,
151
152
} ) ,
152
153
} ,
153
- {
154
- onCancel,
155
- } ,
154
+ { onCancel } ,
156
155
) ;
157
156
158
157
return {
You can’t perform that action at this time.
0 commit comments