Skip to content

Commit 0d37adb

Browse files
committed
fix: improve providing project name
1 parent d695144 commit 0d37adb

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

packages/cli/src/commands/init/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import init from './init';
33
export default {
44
func: init,
55
detached: true,
6-
name: 'init <projectName>',
6+
name: 'init [projectName]',
77
description:
8-
'Initialize a new React Native project named <projectName> in a directory of the same name.',
8+
'Initialize a new React Native project in a directory of the same name.',
99
options: [
1010
{
1111
name: '--version <string>',

packages/cli/src/commands/init/init.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import TemplateAndVersionError from './errors/TemplateAndVersionError';
2424
import {getBunVersionIfAvailable} from '../../tools/bun';
2525
import {getNpmVersionIfAvailable} from '../../tools/npm';
2626
import {getYarnVersionIfAvailable} from '../../tools/yarn';
27+
import prompts from 'prompts';
2728

2829
const DEFAULT_VERSION = 'latest';
2930

@@ -274,6 +275,15 @@ export default (async function initialize(
274275
[projectName]: Array<string>,
275276
options: Options,
276277
) {
278+
if (!projectName) {
279+
const {projName} = await prompts({
280+
type: 'text',
281+
name: 'projName',
282+
message: 'What is the project name?',
283+
});
284+
projectName = projName;
285+
}
286+
277287
validateProjectName(projectName);
278288

279289
if (!!options.template && !!options.version) {

0 commit comments

Comments
 (0)