Skip to content

Commit fc3ab46

Browse files
Juan Sotogaearon
Juan Soto
authored andcommitted
Add ES5 version of path-exists to CLI
1 parent e333b8b commit fc3ab46

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

global-cli/index.js

+14-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ var spawn = require('cross-spawn');
4141
var chalk = require('chalk');
4242
var semver = require('semver');
4343
var argv = require('minimist')(process.argv.slice(2));
44-
var pathExists = require('path-exists');
4544

4645
/**
4746
* Arguments:
@@ -73,7 +72,7 @@ function createApp(name, verbose, version) {
7372

7473
checkAppName(appName);
7574

76-
if (!pathExists.sync(name)) {
75+
if (!pathExistsSync(name)) {
7776
fs.mkdirSync(root);
7877
} else if (!isSafeToCreateProjectIn(root)) {
7978
console.log('The directory `' + name + '` contains file(s) that could conflict. Aborting.');
@@ -205,3 +204,16 @@ function isSafeToCreateProjectIn(root) {
205204
return validFiles.indexOf(file) >= 0;
206205
});
207206
}
207+
208+
// This is an ES5 version of https://github.com/sindresorhus/path-exists.
209+
// The reason it exists is so that the CLI doesn't break before being able to
210+
// warn the user they're using an unsupported version of Node.
211+
// See https://github.com/facebookincubator/create-react-app/issues/570
212+
function pathExistsSync(fp) {
213+
try {
214+
fs.accessSync(fp);
215+
return true;
216+
} catch (err) {
217+
return false;
218+
}
219+
}

global-cli/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
"chalk": "^1.1.1",
2424
"cross-spawn": "^4.0.0",
2525
"minimist": "^1.2.0",
26-
"path-exists": "^3.0.0",
2726
"semver": "^5.0.3"
2827
}
2928
}

0 commit comments

Comments
 (0)