@@ -358,7 +358,7 @@ async function create(_argv: yargs.Arguments<any>) {
358
358
359
359
const questions : ( Omit < PromptObject < keyof Answers > , 'validate' | 'name' > & {
360
360
validate ?: ( value : string ) => boolean | string ;
361
- name : string ;
361
+ name : keyof Answers ;
362
362
} ) [ ] = [
363
363
{
364
364
type : 'text' ,
@@ -521,6 +521,8 @@ async function create(_argv: yargs.Arguments<any>) {
521
521
// Validate arguments passed to the CLI
522
522
validate ( argv ) ;
523
523
524
+ const singleChoiceAnswers : Partial < Answers > = { } ;
525
+
524
526
const answers = {
525
527
...argv ,
526
528
local,
@@ -540,6 +542,8 @@ async function create(_argv: yargs.Arguments<any>) {
540
542
Array . isArray ( question . choices ) &&
541
543
question . choices . length === 1
542
544
) {
545
+ const onlyChoice = question . choices [ 0 ] ! ;
546
+ singleChoiceAnswers [ question . name ] = onlyChoice . value ;
543
547
return false ;
544
548
}
545
549
@@ -554,8 +558,9 @@ async function create(_argv: yargs.Arguments<any>) {
554
558
...question ,
555
559
type : ( prev , values , prompt ) => {
556
560
const result = choices ( prev , { ...argv , ...values } , prompt ) ;
557
-
558
561
if ( result && result . length === 1 ) {
562
+ const onlyChoice = result [ 0 ] ! ;
563
+ singleChoiceAnswers [ question . name ] = onlyChoice . value ;
559
564
return null ;
560
565
}
561
566
@@ -567,6 +572,7 @@ async function create(_argv: yargs.Arguments<any>) {
567
572
return question ;
568
573
} )
569
574
) ) ,
575
+ ...singleChoiceAnswers ,
570
576
} as Answers ;
571
577
572
578
validate ( answers ) ;
0 commit comments