@@ -70,6 +70,9 @@ function parseSchematicName(str) {
70
70
}
71
71
return { collection, schematic } ;
72
72
}
73
+ function removeLeadingSlash ( value ) {
74
+ return value [ 0 ] === '/' ? value . slice ( 1 ) : value ;
75
+ }
73
76
function _listSchematics ( workflow , collectionName , logger ) {
74
77
try {
75
78
const collection = workflow . engine . createCollection ( collectionName ) ;
@@ -99,24 +102,21 @@ function _createPromptProvider() {
99
102
if ( ! definition . items ?. length ) {
100
103
continue ;
101
104
}
102
- const choices = definition . items ?. map ( ( item ) => {
103
- return typeof item == 'string'
105
+ answers [ definition . id ] = await ( definition . multiselect ? prompts . checkbox : prompts . select ) ( {
106
+ message : definition . message ,
107
+ default : definition . default ,
108
+ choices : definition . items . map ( ( item ) => typeof item == 'string'
104
109
? {
105
110
name : item ,
106
111
value : item ,
107
112
}
108
113
: {
109
114
name : item . label ,
110
115
value : item . value ,
111
- } ;
112
- } ) ;
113
- answers [ definition . id ] = await ( definition . multiselect ? prompts . checkbox : prompts . select ) ( {
114
- message : definition . message ,
115
- default : definition . default ,
116
- choices,
116
+ } ) ,
117
117
} ) ;
118
118
break ;
119
- case 'input' :
119
+ case 'input' : {
120
120
let finalValue ;
121
121
answers [ definition . id ] = await prompts . input ( {
122
122
message : definition . message ,
@@ -156,6 +156,7 @@ function _createPromptProvider() {
156
156
answers [ definition . id ] = finalValue ;
157
157
}
158
158
break ;
159
+ }
159
160
}
160
161
}
161
162
return answers ;
@@ -260,12 +261,11 @@ async function main({ args, stdout = process.stdout, stderr = process.stderr, })
260
261
workflow . reporter . subscribe ( ( event ) => {
261
262
nothingDone = false ;
262
263
// Strip leading slash to prevent confusion.
263
- const eventPath = event . path . startsWith ( '/' ) ? event . path . slice ( 1 ) : event . path ;
264
+ const eventPath = removeLeadingSlash ( event . path ) ;
264
265
switch ( event . kind ) {
265
266
case 'error' :
266
267
error = true ;
267
- const desc = event . description == 'alreadyExist' ? 'already exists' : 'does not exist' ;
268
- logger . error ( `ERROR! ${ eventPath } ${ desc } .` ) ;
268
+ logger . error ( `ERROR! ${ eventPath } ${ event . description == 'alreadyExist' ? 'already exists' : 'does not exist' } .` ) ;
269
269
break ;
270
270
case 'update' :
271
271
loggingQueue . push ( `${ colors . cyan ( 'UPDATE' ) } ${ eventPath } (${ event . content . length } bytes)` ) ;
@@ -277,8 +277,7 @@ async function main({ args, stdout = process.stdout, stderr = process.stderr, })
277
277
loggingQueue . push ( `${ colors . yellow ( 'DELETE' ) } ${ eventPath } ` ) ;
278
278
break ;
279
279
case 'rename' :
280
- const eventToPath = event . to . startsWith ( '/' ) ? event . to . slice ( 1 ) : event . to ;
281
- loggingQueue . push ( `${ colors . blue ( 'RENAME' ) } ${ eventPath } => ${ eventToPath } ` ) ;
280
+ loggingQueue . push ( `${ colors . blue ( 'RENAME' ) } ${ eventPath } => ${ removeLeadingSlash ( event . to ) } ` ) ;
282
281
break ;
283
282
}
284
283
} ) ;
0 commit comments