diff --git a/global-cli/index.js b/global-cli/index.js index 9a298b83a61..dc6262b71ac 100644 --- a/global-cli/index.js +++ b/global-cli/index.js @@ -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); } @@ -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) {