workaround transient npm failures (#4989)

This commit is contained in:
Alex Lam S.L
2021-05-30 10:19:29 +01:00
committed by GitHub
parent 06e3dbc089
commit f4f0d2a2dd
11 changed files with 95 additions and 21 deletions

View File

@@ -58,22 +58,29 @@ if (typeof phantom == "undefined") {
}).listen();
server.on("listening", function() {
var port = server.address().port;
if (debug) {
console.log("http://localhost:" + port + "/");
} else (function install() {
child_process.spawn(process.platform == "win32" ? "npm.cmd" : "npm", [
if (debug) return console.log("http://localhost:" + port + "/");
var cmd = process.platform == "win32" ? "npm.cmd" : "npm";
function npm(args, done) {
child_process.spawn(cmd, args, { stdio: [ "ignore", 1, 2 ] }).on("exit", done);
}
(function install() {
npm([
"install",
"phantomjs-prebuilt@2.1.14",
"--no-audit",
"--no-optional",
"--no-save",
"--no-update-notifier",
], {
stdio: [ "ignore", 1, 2 ]
}).on("exit", function(code) {
], function(code) {
if (code) {
console.log("npm install failed with code", code);
return install();
return npm([
"cache",
"clean",
"--force",
], install);
}
var program = require("phantomjs-prebuilt").exec(process.argv[1], port);
program.stdout.pipe(process.stdout);