From fc3ab46d2a54f142f9287ce7de9ab2fc2514487d Mon Sep 17 00:00:00 2001
From: Juan Soto <juan@juansoto.me>
Date: Fri, 9 Sep 2016 20:12:30 -0400
Subject: [PATCH] Add ES5 version of `path-exists` to CLI

---
 global-cli/index.js     | 16 ++++++++++++++--
 global-cli/package.json |  1 -
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/global-cli/index.js b/global-cli/index.js
index 3fc6315e7..fdee78636 100644
--- a/global-cli/index.js
+++ b/global-cli/index.js
@@ -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;
+  }
+}
diff --git a/global-cli/package.json b/global-cli/package.json
index cd4008fef..08f5ac2f8 100644
--- a/global-cli/package.json
+++ b/global-cli/package.json
@@ -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"
   }
 }
-- 
GitLab