Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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