Skip to content

Commit 7b86b81

Browse files
denofevilfeiqitian
authored andcommitted
ignore .idea folder (facebook#522)
* ignore .idea folder this change is requred for IntelliJ-based products because project information files are written before actual generator is invoked * better method name and explanation
1 parent 1e60509 commit 7b86b81

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

Diff for: global-cli/index.js

+6-5
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ function createApp(name, verbose, version) {
7171
var root = path.resolve(name);
7272
if (!pathExists.sync(name)) {
7373
fs.mkdirSync(root);
74-
} else if (!isGitHubBoilerplate(root)) {
74+
} else if (!isSafeToCreateProjectIn(root)) {
7575
console.log('The directory `' + name + '` contains file(s) that could conflict. Aborting.');
7676
process.exit(1);
7777
}
@@ -167,11 +167,12 @@ function checkNodeVersion() {
167167
}
168168
}
169169

170-
// Check if GitHub boilerplate compatible
171-
// https://github.com/facebookincubator/create-react-app/pull/368#issuecomment-237875655
172-
function isGitHubBoilerplate(root) {
170+
// If project only contains files generated by GH, it’s safe.
171+
// We also special case IJ-based products .idea because it integrates with CRA:
172+
// https://github.com/facebookincubator/create-react-app/pull/368#issuecomment-243446094
173+
function isSafeToCreateProjectIn(root) {
173174
var validFiles = [
174-
'.DS_Store', 'Thumbs.db', '.git', '.gitignore', 'README.md', 'LICENSE'
175+
'.DS_Store', 'Thumbs.db', '.git', '.gitignore', '.idea', 'README.md', 'LICENSE'
175176
];
176177
return fs.readdirSync(root)
177178
.every(function(file) {

0 commit comments

Comments
 (0)