Skip to content

Commit

Permalink
Add ES5 version of path-exists to CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
Juan Soto authored and gaearon committed Sep 16, 2016
1 parent e333b8b commit fc3ab46
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
16 changes: 14 additions & 2 deletions global-cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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.');
Expand Down Expand Up @@ -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;
}
}
1 change: 0 additions & 1 deletion global-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}

0 comments on commit fc3ab46

Please sign in to comment.