Skip to content

Use minimist to parse arguments #6338

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion packages/create-react-app/createReactApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,15 @@ const errorLogFilePatterns = [

let projectName;

const validateArgs = args => {
let hasSwitch = args.find(arg => arg.includes('-'))
if (hasSwitch) {
let index = args.indexOf(hasSwitch)
args.splice(index, 2)
}
return args
}

const program = new commander.Command(packageJson.name)
.version(packageJson.version)
.arguments('<project-directory>')
Expand Down Expand Up @@ -144,7 +153,7 @@ if (program.info) {
}

const hasMultipleProjectNameArgs =
process.argv[3] && !process.argv[3].startsWith('-');
validateArgs(process.argv.slice(2)).length > 1;
if (typeof projectName === 'undefined' || hasMultipleProjectNameArgs) {
console.log();
if (hasMultipleProjectNameArgs) {
Expand Down