Index: build_apprtc_appengine_app.py |
diff --git a/build_apprtc_appengine_app.py b/build_apprtc_appengine_app.py |
index c1f91b2035a7a603024d7b6dabe361799ded88b6..9d15b7557afed2b10a12461237269280b6f52f6e 100755 |
--- a/build_apprtc_appengine_app.py |
+++ b/build_apprtc_appengine_app.py |
@@ -12,6 +12,7 @@ the node toolchain we downloaded earlier. |
import fileinput |
import os |
import shutil |
+import subprocess |
import sys |
import utils |
@@ -30,6 +31,14 @@ def _WorkaroundPhantomJsOnWin(samples_path): |
sys.stdout.write(line) |
+def _WorkAroundMacNpmCorruptedDataOnInstall(command): |
+ print 'Wiping .npm folder and trying again...' |
+ npm_storage = os.path.expanduser('~/.npm') |
+ assert npm_storage.endswith('.npm') |
+ shutil.rmtree(npm_storage, ignore_errors=True) |
+ utils.RunSubprocessWithRetry(command) |
+ |
+ |
def main(): |
node_path = os.path.abspath('node') |
if not os.path.exists(node_path): |
@@ -48,7 +57,14 @@ def main(): |
npm_bin = os.path.join(node_path, 'bin', 'npm') |
node_bin = os.path.join(node_path, 'bin', 'node') |
- utils.RunSubprocessWithRetry([npm_bin, 'install']) |
+ command = [npm_bin, 'install'] |
+ try: |
+ utils.RunSubprocessWithRetry(command) |
+ except subprocess.CalledProcessError: |
+ if utils.GetPlatform() is not 'mac': |
+ raise |
+ _WorkAroundMacNpmCorruptedDataOnInstall(command) |
+ |
local_grunt_bin = os.path.join('node_modules', 'grunt-cli', 'bin', 'grunt') |
if not os.path.exists(local_grunt_bin): |