Skip to content

Commit

Permalink
fix: don't create example app for local library
Browse files Browse the repository at this point in the history
  • Loading branch information
satya164 committed Dec 9, 2024
1 parent b8c3293 commit 4f64b22
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
2 changes: 1 addition & 1 deletion packages/create-react-native-library/src/inform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export async function printNextSteps(
)} to link the library\n`
: `- Link the library at ${kleur.blue(
path.relative(process.cwd(), folder)
)} based on your project setup'\n`) +
)} based on your project setup\n`) +
`- Run ${kleur.blue(
'pod install --project-directory=ios'
)} to install dependencies with CocoaPods\n` +
Expand Down
18 changes: 12 additions & 6 deletions packages/create-react-native-library/src/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,14 +282,20 @@ export async function createQuestions({
});
},
},
];

if (!local) {
questions.push({
{
type: 'select',
name: 'example',
message: 'What type of example app do you want to create?',
choices: (_, values) => {
if (local) {
return [
{
title: 'None',
value: 'none',
},
];
}

return EXAMPLE_CHOICES.filter((choice) => {
if (values.type) {
return values.type === 'library'
Expand All @@ -300,8 +306,8 @@ export async function createQuestions({
return true;
});
},
});
}
},
];

return questions;
}
Expand Down
10 changes: 7 additions & 3 deletions packages/create-react-native-library/src/utils/prompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,14 @@ export async function prompt<T extends string>(
continue;
}

const { type, choices } = question;

// Don't prompt questions with a single choice
if (Array.isArray(question.choices) && question.choices.length === 1) {
if (
type === 'select' &&
Array.isArray(question.choices) &&
question.choices.length === 1
) {
const onlyChoice = question.choices[0];

if (onlyChoice?.value) {
Expand All @@ -54,8 +60,6 @@ export async function prompt<T extends string>(
continue;
}

const { type, choices } = question;

// Don't prompt dynamic questions with a single choice
if (type === 'select' && typeof choices === 'function') {
question.type = (prev, values) => {
Expand Down

0 comments on commit 4f64b22

Please sign in to comment.