From 31aa1a67e23752c0adb8502e5dd4d43b304f7aef Mon Sep 17 00:00:00 2001
From: Greg Magolan <gmagolan@gmail.com>
Date: Fri, 2 Aug 2019 23:18:12 -0700
Subject: [PATCH] fix: fix yarn_install yarn cache mutex bug

---
 internal/npm_install/pre_process_package_json.js | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/internal/npm_install/pre_process_package_json.js b/internal/npm_install/pre_process_package_json.js
index ecd4111b2c..8e85318a53 100644
--- a/internal/npm_install/pre_process_package_json.js
+++ b/internal/npm_install/pre_process_package_json.js
@@ -86,10 +86,11 @@ function clearYarnFilePathCaches(pkg) {
 
   if (clearPackages.length) {
     if (DEBUG) console.error(`Cleaning packages from yarn cache: ${clearPackages.join(' ')}`);
-
-    child_process.execFileSync(
-        'yarn', ['cache', 'clean'].concat(clearPackages),
-        {stdio: [process.stdin, process.stdout, process.stderr]});
+    for (const c of clearPackages) {
+      child_process.execFileSync(
+          'yarn', ['--mutex', 'network', 'cache', 'clean', c],
+          {stdio: [process.stdin, process.stdout, process.stderr]});
+    }
   }
 }