From: Alex Lam S.L Date: Sat, 24 Oct 2020 03:22:13 +0000 (+0100) Subject: improve resilience against `npm` failures (#4239) X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=ff38d2471f36815f3d56774092a8d298719fd4fb;p=UglifyJS.git improve resilience against `npm` failures (#4239) --- 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 {