Skip to content

Commit 4f64b22

Browse files
committed
fix: don't create example app for local library
1 parent b8c3293 commit 4f64b22

File tree

3 files changed

+20
-10
lines changed

3 files changed

+20
-10
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export async function printNextSteps(
5454
)} to link the library\n`
5555
: `- Link the library at ${kleur.blue(
5656
path.relative(process.cwd(), folder)
57-
)} based on your project setup'\n`) +
57+
)} based on your project setup\n`) +
5858
`- Run ${kleur.blue(
5959
'pod install --project-directory=ios'
6060
)} to install dependencies with CocoaPods\n` +

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

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -282,14 +282,20 @@ export async function createQuestions({
282282
});
283283
},
284284
},
285-
];
286-
287-
if (!local) {
288-
questions.push({
285+
{
289286
type: 'select',
290287
name: 'example',
291288
message: 'What type of example app do you want to create?',
292289
choices: (_, values) => {
290+
if (local) {
291+
return [
292+
{
293+
title: 'None',
294+
value: 'none',
295+
},
296+
];
297+
}
298+
293299
return EXAMPLE_CHOICES.filter((choice) => {
294300
if (values.type) {
295301
return values.type === 'library'
@@ -300,8 +306,8 @@ export async function createQuestions({
300306
return true;
301307
});
302308
},
303-
});
304-
}
309+
},
310+
];
305311

306312
return questions;
307313
}

packages/create-react-native-library/src/utils/prompt.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,14 @@ export async function prompt<T extends string>(
4242
continue;
4343
}
4444

45+
const { type, choices } = question;
46+
4547
// Don't prompt questions with a single choice
46-
if (Array.isArray(question.choices) && question.choices.length === 1) {
48+
if (
49+
type === 'select' &&
50+
Array.isArray(question.choices) &&
51+
question.choices.length === 1
52+
) {
4753
const onlyChoice = question.choices[0];
4854

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

57-
const { type, choices } = question;
58-
5963
// Don't prompt dynamic questions with a single choice
6064
if (type === 'select' && typeof choices === 'function') {
6165
question.type = (prev, values) => {

0 commit comments

Comments
 (0)