diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2020-10-24 04:22:13 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-24 11:22:13 +0800 |
commit | ff38d2471f36815f3d56774092a8d298719fd4fb (patch) | |
tree | dcda4ef0d2023a8ff9d59350be8c489d5f32df1f /test/jetstream.js | |
parent | 8e86d05c3228635ad969e38ce5f90b2a75d1885c (diff) | |
download | tracifyjs-ff38d2471f36815f3d56774092a8d298719fd4fb.tar.gz tracifyjs-ff38d2471f36815f3d56774092a8d298719fd4fb.zip |
improve resilience against `npm` failures (#4239)
Diffstat (limited to 'test/jetstream.js')
-rw-r--r-- | test/jetstream.js | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/test/jetstream.js b/test/jetstream.js index 23c49b05..1eebdc6b 100644 --- a/test/jetstream.js +++ b/test/jetstream.js @@ -60,7 +60,7 @@ if (typeof phantom == "undefined") { var port = server.address().port; if (debug) { console.log("http://localhost:" + port + "/"); - } else { + } else (function install() { child_process.spawn(process.platform == "win32" ? "npm.cmd" : "npm", [ "install", "phantomjs-prebuilt@2.1.14", @@ -71,7 +71,10 @@ if (typeof phantom == "undefined") { ], { stdio: [ "ignore", 1, 2 ] }).on("exit", function(code) { - if (code) throw new Error("npm install failed!"); + if (code) { + console.log("npm install failed with code", code); + return install(); + } var program = require("phantomjs-prebuilt").exec(process.argv[1], port); program.stdout.pipe(process.stdout); program.stderr.pipe(process.stderr); @@ -82,7 +85,7 @@ if (typeof phantom == "undefined") { process.exit(0); }); }); - } + })(); }); server.timeout = 0; } else { |