mirror of
https://github.com/zhigang1992/create-react-app.git
synced 2026-01-12 22:46:30 +08:00
Check for multiple project names when initializing (#6080)
This commit is contained in:
committed by
Brody McKee
parent
af339ec343
commit
a78be99b5e
@@ -143,11 +143,24 @@ if (program.info) {
|
||||
.then(console.log);
|
||||
}
|
||||
|
||||
if (typeof projectName === 'undefined') {
|
||||
console.error('Please specify the project directory:');
|
||||
console.log(
|
||||
` ${chalk.cyan(program.name())} ${chalk.green('<project-directory>')}`
|
||||
);
|
||||
const hasMultipleProjectNameArgs =
|
||||
process.argv[3] && !process.argv[3].startsWith('-');
|
||||
if (typeof projectName === 'undefined' || hasMultipleProjectNameArgs) {
|
||||
console.log();
|
||||
if (hasMultipleProjectNameArgs) {
|
||||
console.error(
|
||||
`You have provided more than one argument for ${chalk.green(
|
||||
'<project-directory>'
|
||||
)}.`
|
||||
);
|
||||
console.log();
|
||||
console.log('Please specify only one project directory, without spaces.');
|
||||
} else {
|
||||
console.error('Please specify the project directory:');
|
||||
console.log(
|
||||
` ${chalk.cyan(program.name())} ${chalk.green('<project-directory>')}`
|
||||
);
|
||||
}
|
||||
console.log();
|
||||
console.log('For example:');
|
||||
console.log(` ${chalk.cyan(program.name())} ${chalk.green('my-react-app')}`);
|
||||
|
||||
Reference in New Issue
Block a user