-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
Check the app name before proceeding. #628
Conversation
Thanks, the check seems to work 👍 I think the message with big screaming red capital letters sounds a bit too aggressive? I would go with something friendlier like `Can't use "react" as the name of the app, because a dependency with the same name exists. Please use a different name.` (`"react"` here would be the conflicting name the user tried to use.) |
@@ -69,14 +69,18 @@ createApp(commands[0], argv.verbose, argv['scripts-version']); | |||
|
|||
function createApp(name, verbose, version) { | |||
var root = path.resolve(name); | |||
var appName = path.basename(root); | |||
|
|||
// NPM is whining about installing packages with names equal to appName. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment can be removed.
I'm open to suggestions. I just felt like listing all disallowed package names might be a good idea to keep users sane. Uppercased I like that it emphasizes the following list of names EDIT: Would changing the color to yellow make any difference? Also listed names could be white. EDIT2: Or just removing the bold face? |
We could rephrase it to:
|
I think the rephrased message looks alright, except for the all caps |
// TODO: there should be a single place that holds the dependencies | ||
var dependencies = ['react', 'react-dom'] | ||
var devDependencies = ['react-scripts'] | ||
var allDependencies = dependencies.concat(devDependencies).sort() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing a few semicolons here.
Looks good to me too! |
Thank you @mareksuscak! |
Thanks for adding this error message! If we are to nitpick on In a standard context, In this case, the user literally This is not a big deal so feel free to ignore this message, I just wanted to share my opinion :) |
Agree. How about we change it to "Due to the way npm works, you can't use the following names:"? Also note the change from passive to active verb, it reads friendlier. |
@gaearon just to confirm before I jump on it you meant to change the message to:
|
if (allDependencies.indexOf(appName) >= 0) { | ||
console.error( | ||
chalk.red( | ||
`Can't use "${appName}" as the app name because a dependency with the same name exists.\n\n` + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file can’t use template strings. It’s meant to be runnable in older nodes, at least until we warn about unsupported version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, I'm very sorry. I've got confused by this line but now I realized it's for create-react-app project itself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mareksuscak The requirement for Node >= 4 is correct, however we want this entry point file to still run in older versions, so that instead of just crashing, we can show a warning, if someone tries to use an unsupported version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, good then. Didn't know. Thanks for explaining.
Tweaked in 061aa2c. |
* Check the app name before proceeding. * Refactor. * Use arrow function and template string. * Remove comment. * Rephrase the error. * Add missing semicolons.
Fixes #616.