From 1b645e2cc4de1f3b140a7306347fd742ba2cb155 Mon Sep 17 00:00:00 2001
From: Ville Immonen <ville.immonen@iki.fi>
Date: Mon, 9 Jan 2017 17:25:31 +0200
Subject: [PATCH] Use yarnpkg alias to run Yarn (#1365)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

There’s a common tool included in Hadoop that also has a `yarn` command,
which created issues for users who had Hadoop installed:
* #1257
* #1363

Yarn also installs the command under `yarnpkg` alias (added in
https://github.com/yarnpkg/yarn/commit/cefa9a368dd3df1a1f1ecd9e50de9c5fabefbc92)
so we can use `yarnpkg` instead of `yarn` to make it more reliable.

This has no effect on users who don't have Hadoop installed, but those
who have won't see errors from falsely detecting Hadoop Yarn as Yarn
the package manager, and they can now also install Yarn to make use of
our Yarn support without the Hadoop Yarn interfering.
---
 packages/create-react-app/index.js      | 4 ++--
 packages/react-scripts/scripts/eject.js | 2 +-
 packages/react-scripts/scripts/init.js  | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/packages/create-react-app/index.js b/packages/create-react-app/index.js
index ab356d4d7..9ab11a5e9 100644
--- a/packages/create-react-app/index.js
+++ b/packages/create-react-app/index.js
@@ -135,7 +135,7 @@ function createApp(name, verbose, version) {
 
 function shouldUseYarn() {
   try {
-    execSync('yarn --version', {stdio: 'ignore'});
+    execSync('yarnpkg --version', {stdio: 'ignore'});
     return true;
   } catch (e) {
     return false;
@@ -146,7 +146,7 @@ function install(packageToInstall, verbose, callback) {
   var command;
   var args;
   if (shouldUseYarn()) {
-    command = 'yarn';
+    command = 'yarnpkg';
     args = [ 'add', '--dev', '--exact', packageToInstall];
   } else {
     command = 'npm';
diff --git a/packages/react-scripts/scripts/eject.js b/packages/react-scripts/scripts/eject.js
index aeed2967d..86dbc15c3 100644
--- a/packages/react-scripts/scripts/eject.js
+++ b/packages/react-scripts/scripts/eject.js
@@ -146,7 +146,7 @@ prompt(
   if (fs.existsSync(paths.yarnLockFile)) {
     console.log(cyan('Running yarn...'));
     fs.removeSync(ownPath);
-    spawnSync('yarn', [], {stdio: 'inherit'});
+    spawnSync('yarnpkg', [], {stdio: 'inherit'});
   } else {
     console.log(cyan('Running npm install...'));
     fs.removeSync(ownPath);
diff --git a/packages/react-scripts/scripts/init.js b/packages/react-scripts/scripts/init.js
index 63daf3452..e438e5a2e 100644
--- a/packages/react-scripts/scripts/init.js
+++ b/packages/react-scripts/scripts/init.js
@@ -64,7 +64,7 @@ module.exports = function(appPath, appName, verbose, originalDirectory) {
   var args;
 
   if (useYarn) {
-    command = 'yarn';
+    command = 'yarnpkg';
     args = ['add'];
   } else {
     command = 'npm';
-- 
GitLab