From 03a1f0bcdee97e43a9a7ec65e92cc19a65752582 Mon Sep 17 00:00:00 2001
From: Ro Savage <rowan.savage@gmail.com>
Date: Mon, 29 May 2017 05:45:53 +1200
Subject: [PATCH 1/3] Added cache clear to e2e scripts

---
 tasks/e2e-installs.sh    | 11 +++++++++++
 tasks/e2e-kitchensink.sh | 11 +++++++++++
 tasks/e2e-simple.sh      | 11 +++++++++++
 3 files changed, 33 insertions(+)

diff --git a/tasks/e2e-installs.sh b/tasks/e2e-installs.sh
index b27b1239eda..064a4e30f0a 100755
--- a/tasks/e2e-installs.sh
+++ b/tasks/e2e-installs.sh
@@ -83,6 +83,17 @@ set -x
 cd ..
 root_path=$PWD
 
+# Clear cache to avoid issues with incorrect packages being used
+if hash yarnpkg 2>/dev/null
+then
+  yarn cache clean
+fi
+
+if hash npm 2>/dev/null
+then
+  npm cache clean
+fi
+
 # Prevent lerna bootstrap, we only want top-level dependencies
 cp package.json package.json.bak
 grep -v "lerna bootstrap" package.json > temp && mv temp package.json
diff --git a/tasks/e2e-kitchensink.sh b/tasks/e2e-kitchensink.sh
index 9e689ca222e..157064a50fb 100755
--- a/tasks/e2e-kitchensink.sh
+++ b/tasks/e2e-kitchensink.sh
@@ -66,6 +66,17 @@ set -x
 cd ..
 root_path=$PWD
 
+# Clear cache to avoid issues with incorrect packages being used
+if hash yarnpkg 2>/dev/null
+then
+  yarn cache clean
+fi
+
+if hash npm 2>/dev/null
+then
+  npm cache clean
+fi
+
 # Prevent lerna bootstrap, we only want top-level dependencies
 cp package.json package.json.bak
 grep -v "lerna bootstrap" package.json > temp && mv temp package.json
diff --git a/tasks/e2e-simple.sh b/tasks/e2e-simple.sh
index 4795d09a8b2..08e359517ed 100755
--- a/tasks/e2e-simple.sh
+++ b/tasks/e2e-simple.sh
@@ -65,6 +65,17 @@ set -x
 cd ..
 root_path=$PWD
 
+# Clear cache to avoid issues with incorrect packages being used
+if hash yarnpkg 2>/dev/null
+then
+  yarn cache clean
+fi
+
+if hash npm 2>/dev/null
+then
+  npm cache clean
+fi
+
 # Prevent lerna bootstrap, we only want top-level dependencies
 cp package.json package.json.bak
 grep -v "lerna bootstrap" package.json > temp && mv temp package.json

From 8928aa5219b09090c623dcf0801d761b3a1b7260 Mon Sep 17 00:00:00 2001
From: Ro Savage <rowan.savage@gmail.com>
Date: Mon, 29 May 2017 14:06:17 +1200
Subject: [PATCH 2/3] Install latest yarn on AppVeyor to avoid windows crashing
 bug in yarn

---
 tasks/e2e-installs.sh    | 5 ++++-
 tasks/e2e-kitchensink.sh | 5 ++++-
 tasks/e2e-simple.sh      | 5 ++++-
 3 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/tasks/e2e-installs.sh b/tasks/e2e-installs.sh
index 064a4e30f0a..0bdbbad6b56 100755
--- a/tasks/e2e-installs.sh
+++ b/tasks/e2e-installs.sh
@@ -86,7 +86,10 @@ root_path=$PWD
 # Clear cache to avoid issues with incorrect packages being used
 if hash yarnpkg 2>/dev/null
 then
-  yarn cache clean
+  # AppVeyor uses old version on yarn.
+  # Once updated to 0.24.3 or above install can be removed.
+  npm install -g yarn@latest
+  yarnpkg cache clean
 fi
 
 if hash npm 2>/dev/null
diff --git a/tasks/e2e-kitchensink.sh b/tasks/e2e-kitchensink.sh
index 157064a50fb..96b249c45c0 100755
--- a/tasks/e2e-kitchensink.sh
+++ b/tasks/e2e-kitchensink.sh
@@ -69,7 +69,10 @@ root_path=$PWD
 # Clear cache to avoid issues with incorrect packages being used
 if hash yarnpkg 2>/dev/null
 then
-  yarn cache clean
+  # AppVeyor uses old version on yarn.
+  # Once updated to 0.24.3 or above install can be removed.
+  npm install -g yarn@latest
+  yarnpkg cache clean
 fi
 
 if hash npm 2>/dev/null
diff --git a/tasks/e2e-simple.sh b/tasks/e2e-simple.sh
index 08e359517ed..abe3ce55878 100755
--- a/tasks/e2e-simple.sh
+++ b/tasks/e2e-simple.sh
@@ -68,7 +68,10 @@ root_path=$PWD
 # Clear cache to avoid issues with incorrect packages being used
 if hash yarnpkg 2>/dev/null
 then
-  yarn cache clean
+  # AppVeyor uses old version on yarn.
+  # Once updated to 0.24.3 or above install can be removed.
+  npm install -g yarn@latest
+  yarnpkg cache clean
 fi
 
 if hash npm 2>/dev/null

From 171e8fc00d4c7d430af7b27564baf3e82e573442 Mon Sep 17 00:00:00 2001
From: Ro Savage <rowan.savage@gmail.com>
Date: Mon, 29 May 2017 14:49:40 +1200
Subject: [PATCH 3/3] Alternative fix for yarn crashing e2e tests on windows
 machines

---
 tasks/e2e-installs.sh    | 18 ++++++++++++++----
 tasks/e2e-kitchensink.sh | 18 ++++++++++++++----
 tasks/e2e-simple.sh      | 18 ++++++++++++++----
 3 files changed, 42 insertions(+), 12 deletions(-)

diff --git a/tasks/e2e-installs.sh b/tasks/e2e-installs.sh
index 0bdbbad6b56..8f4789ff0c7 100755
--- a/tasks/e2e-installs.sh
+++ b/tasks/e2e-installs.sh
@@ -86,10 +86,20 @@ root_path=$PWD
 # Clear cache to avoid issues with incorrect packages being used
 if hash yarnpkg 2>/dev/null
 then
-  # AppVeyor uses old version on yarn.
-  # Once updated to 0.24.3 or above install can be removed.
-  npm install -g yarn@latest
-  yarnpkg cache clean
+  # AppVeyor uses an old version of yarn.
+  # Once updated to 0.24.3 or above, the workaround can be removed
+  # and replaced with `yarnpkg cache clean`
+  # Issues: 
+  #    https://github.com/yarnpkg/yarn/issues/2591
+  #    https://github.com/appveyor/ci/issues/1576
+  #    https://github.com/facebookincubator/create-react-app/pull/2400
+  # When removing workaround, you may run into
+  #    https://github.com/facebookincubator/create-react-app/issues/2030
+  case "$(uname -s)" in
+    *CYGWIN*|MSYS*|MINGW*) yarn=yarn.cmd;;
+    *) yarn=yarnpkg;;
+  esac
+  $yarn cache clean
 fi
 
 if hash npm 2>/dev/null
diff --git a/tasks/e2e-kitchensink.sh b/tasks/e2e-kitchensink.sh
index 96b249c45c0..6270f00ac04 100755
--- a/tasks/e2e-kitchensink.sh
+++ b/tasks/e2e-kitchensink.sh
@@ -69,10 +69,20 @@ root_path=$PWD
 # Clear cache to avoid issues with incorrect packages being used
 if hash yarnpkg 2>/dev/null
 then
-  # AppVeyor uses old version on yarn.
-  # Once updated to 0.24.3 or above install can be removed.
-  npm install -g yarn@latest
-  yarnpkg cache clean
+  # AppVeyor uses an old version of yarn.
+  # Once updated to 0.24.3 or above, the workaround can be removed
+  # and replaced with `yarnpkg cache clean`
+  # Issues: 
+  #    https://github.com/yarnpkg/yarn/issues/2591
+  #    https://github.com/appveyor/ci/issues/1576
+  #    https://github.com/facebookincubator/create-react-app/pull/2400
+  # When removing workaround, you may run into
+  #    https://github.com/facebookincubator/create-react-app/issues/2030
+  case "$(uname -s)" in
+    *CYGWIN*|MSYS*|MINGW*) yarn=yarn.cmd;;
+    *) yarn=yarnpkg;;
+  esac
+  $yarn cache clean
 fi
 
 if hash npm 2>/dev/null
diff --git a/tasks/e2e-simple.sh b/tasks/e2e-simple.sh
index abe3ce55878..163bec0818a 100755
--- a/tasks/e2e-simple.sh
+++ b/tasks/e2e-simple.sh
@@ -68,10 +68,20 @@ root_path=$PWD
 # Clear cache to avoid issues with incorrect packages being used
 if hash yarnpkg 2>/dev/null
 then
-  # AppVeyor uses old version on yarn.
-  # Once updated to 0.24.3 or above install can be removed.
-  npm install -g yarn@latest
-  yarnpkg cache clean
+  # AppVeyor uses an old version of yarn.
+  # Once updated to 0.24.3 or above, the workaround can be removed
+  # and replaced with `yarnpkg cache clean`
+  # Issues: 
+  #    https://github.com/yarnpkg/yarn/issues/2591
+  #    https://github.com/appveyor/ci/issues/1576
+  #    https://github.com/facebookincubator/create-react-app/pull/2400
+  # When removing workaround, you may run into
+  #    https://github.com/facebookincubator/create-react-app/issues/2030
+  case "$(uname -s)" in
+    *CYGWIN*|MSYS*|MINGW*) yarn=yarn.cmd;;
+    *) yarn=yarnpkg;;
+  esac
+  $yarn cache clean
 fi
 
 if hash npm 2>/dev/null