-
-
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
Change error wording and list conflicting files when initializing app #2785
Conversation
@@ -585,7 +581,30 @@ function isSafeToCreateProjectIn(root) { | |||
'.hgignore', | |||
'.hgcheck', | |||
]; | |||
return fs.readdirSync(root).every(file => validFiles.indexOf(file) >= 0); | |||
console.log(); | |||
let conflicts = fs.readdirSync(root).map((file, index) => { |
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 could be accomplished more succinctly with a filter:
const conflicts = fs.readdirSync(root).filter(file => !validFiles.includes(file));
} | ||
}); | ||
|
||
if (conflicts.length > 0) { |
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.
How about we invert this for less nesting?
if (conflicts.length < 1) {
return true;
}
)} already exists and contains files that could cause conflicts:` | ||
); | ||
console.log(); | ||
console.log(JSON.stringify(conflicts, null, ' ')); |
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.
I'm not a fan of JSON output; can we list them instead?
for (const file of conflicts) {
console.log(` ${file}`);
}
console.log( | ||
`The directory ${chalk.green( | ||
name | ||
)} already exists and contains files that could cause conflicts:` |
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.
I feel like "already exists" is redundant, the original message should be fine:
`The directory ${chalk.green(name)} contains files that could conflict.`
Cool, updated the requested changes 😃 |
Fantastic! Could you please upload a new picture? |
Beautiful, thank you so much! I switched the period to a colon after conflict. |
Hi there! This change is out in |
* change error wording and list conflicting files when initializing app * update code * Update createReactApp.js
* change error wording and list conflicting files when initializing app * update code * Update createReactApp.js
* change error wording and list conflicting files when initializing app * update code * Update createReactApp.js
* change error wording and list conflicting files when initializing app * update code * Update createReactApp.js
* change error wording and list conflicting files when initializing app * update code * Update createReactApp.js
PR for #2780:
Tested by running
create-react-app
with and without folder containing possible conflicting files: