Commit fc3ab46d authored by Juan Soto's avatar Juan Soto Committed by Dan Abramov
Browse files

Add ES5 version of `path-exists` to CLI

parent e333b8b8
No related merge requests found
Showing with 14 additions and 3 deletions
+14 -3
......@@ -41,7 +41,6 @@ var spawn = require('cross-spawn');
var chalk = require('chalk');
var semver = require('semver');
var argv = require('minimist')(process.argv.slice(2));
var pathExists = require('path-exists');
/**
* Arguments:
......@@ -73,7 +72,7 @@ function createApp(name, verbose, version) {
checkAppName(appName);
if (!pathExists.sync(name)) {
if (!pathExistsSync(name)) {
fs.mkdirSync(root);
} else if (!isSafeToCreateProjectIn(root)) {
console.log('The directory `' + name + '` contains file(s) that could conflict. Aborting.');
......@@ -205,3 +204,16 @@ function isSafeToCreateProjectIn(root) {
return validFiles.indexOf(file) >= 0;
});
}
// This is an ES5 version of https://github.com/sindresorhus/path-exists.
// The reason it exists is so that the CLI doesn't break before being able to
// warn the user they're using an unsupported version of Node.
// See https://github.com/facebookincubator/create-react-app/issues/570
function pathExistsSync(fp) {
try {
fs.accessSync(fp);
return true;
} catch (err) {
return false;
}
}
......@@ -23,7 +23,6 @@
"chalk": "^1.1.1",
"cross-spawn": "^4.0.0",
"minimist": "^1.2.0",
"path-exists": "^3.0.0",
"semver": "^5.0.3"
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment