Skip to content

Commit

Permalink
ignore .idea folder (facebook#522)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
denofevil authored and feiqitian committed Oct 25, 2016
1 parent 1e60509 commit 7b86b81
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions global-cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function createApp(name, verbose, version) {
var root = path.resolve(name);
if (!pathExists.sync(name)) {
fs.mkdirSync(root);
} else if (!isGitHubBoilerplate(root)) {
} else if (!isSafeToCreateProjectIn(root)) {
console.log('The directory `' + name + '` contains file(s) that could conflict. Aborting.');
process.exit(1);
}
Expand Down Expand Up @@ -167,11 +167,12 @@ function checkNodeVersion() {
}
}

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

0 comments on commit 7b86b81

Please sign in to comment.