Skip to content

Commit 3c80800

Browse files
committed
fix: single answer questions dont get stored with metadata
1 parent 091a768 commit 3c80800

File tree

1 file changed

+8
-2
lines changed
  • packages/create-react-native-library/src

1 file changed

+8
-2
lines changed

packages/create-react-native-library/src/index.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ async function create(_argv: yargs.Arguments<any>) {
358358

359359
const questions: (Omit<PromptObject<keyof Answers>, 'validate' | 'name'> & {
360360
validate?: (value: string) => boolean | string;
361-
name: string;
361+
name: keyof Answers;
362362
})[] = [
363363
{
364364
type: 'text',
@@ -521,6 +521,8 @@ async function create(_argv: yargs.Arguments<any>) {
521521
// Validate arguments passed to the CLI
522522
validate(argv);
523523

524+
const singleChoiceAnswers: Partial<Answers> = {};
525+
524526
const answers = {
525527
...argv,
526528
local,
@@ -540,6 +542,8 @@ async function create(_argv: yargs.Arguments<any>) {
540542
Array.isArray(question.choices) &&
541543
question.choices.length === 1
542544
) {
545+
const onlyChoice = question.choices[0]!;
546+
singleChoiceAnswers[question.name] = onlyChoice.value;
543547
return false;
544548
}
545549

@@ -554,8 +558,9 @@ async function create(_argv: yargs.Arguments<any>) {
554558
...question,
555559
type: (prev, values, prompt) => {
556560
const result = choices(prev, { ...argv, ...values }, prompt);
557-
558561
if (result && result.length === 1) {
562+
const onlyChoice = result[0]!;
563+
singleChoiceAnswers[question.name] = onlyChoice.value;
559564
return null;
560565
}
561566

@@ -567,6 +572,7 @@ async function create(_argv: yargs.Arguments<any>) {
567572
return question;
568573
})
569574
)),
575+
...singleChoiceAnswers,
570576
} as Answers;
571577

572578
validate(answers);

0 commit comments

Comments
 (0)