Add coverage to webserver
This commit is contained in:
parent
7ce92211f9
commit
bdcefbe269
|
@ -1,8 +1,8 @@
|
|||
let finalhandler = require('finalhandler');
|
||||
const async = require('async');
|
||||
let http = require('http');
|
||||
let serveStatic = require('serve-static');
|
||||
const {canonicalHost, defaultHost, dockerHostSwap} = require('../../utils/host');
|
||||
const express = require('express');
|
||||
const fs = require('../../core/fs');
|
||||
require('http-shutdown').extend();
|
||||
|
||||
class Server {
|
||||
|
@ -22,11 +22,15 @@ class Server {
|
|||
":" + this.port).bold.underline.green;
|
||||
return callback(null, message);
|
||||
}
|
||||
let serve = serveStatic(this.buildDir, {'index': ['index.html', 'index.htm']});
|
||||
|
||||
this.server = http.createServer(function onRequest(req, res) {
|
||||
serve(req, res, finalhandler(req, res));
|
||||
}).withShutdown();
|
||||
const coverage = serveStatic(fs.dappPath('coverage/__root__/'), {'index': ['index.html', 'index.htm']});
|
||||
const coverageStyle = serveStatic(fs.dappPath('coverage/'));
|
||||
const main = serveStatic(this.buildDir, {'index': ['index.html', 'index.htm']});
|
||||
|
||||
this.app = express();
|
||||
this.app.use(main);
|
||||
this.app.use('/coverage', coverage);
|
||||
this.app.use(coverageStyle);
|
||||
|
||||
const self = this;
|
||||
|
||||
|
@ -39,7 +43,7 @@ class Server {
|
|||
self.events.request('build-placeholder', next);
|
||||
},
|
||||
function listen(next) {
|
||||
self.server.listen(self.port, self.hostname, () => {
|
||||
self.server = self.app.listen(self.port, self.hostname, () => {
|
||||
self.port = self.server.address().port;
|
||||
next();
|
||||
});
|
||||
|
@ -67,7 +71,7 @@ class Server {
|
|||
if (!this.server || !this.server.listening) {
|
||||
return callback(null, __("no webserver is currently running"));
|
||||
}
|
||||
this.server.shutdown(function() {
|
||||
this.server.close(function() {
|
||||
callback(null, __("Webserver stopped"));
|
||||
});
|
||||
}
|
||||
|
|
|
@ -986,7 +986,7 @@
|
|||
"dependencies": {
|
||||
"acorn": {
|
||||
"version": "3.3.0",
|
||||
"resolved": "https://registry.npmjs.org/acorn/-/acorn-3.3.0.tgz",
|
||||
"resolved": "http://registry.npmjs.org/acorn/-/acorn-3.3.0.tgz",
|
||||
"integrity": "sha1-ReN/s56No/JbruP/U2niu18iAXo=",
|
||||
"dev": true
|
||||
}
|
||||
|
@ -1020,7 +1020,7 @@
|
|||
},
|
||||
"ambi": {
|
||||
"version": "2.5.0",
|
||||
"resolved": "https://registry.npmjs.org/ambi/-/ambi-2.5.0.tgz",
|
||||
"resolved": "http://registry.npmjs.org/ambi/-/ambi-2.5.0.tgz",
|
||||
"integrity": "sha1-fI43K+SIkRV+fOoBy2+RQ9H3QiA=",
|
||||
"requires": {
|
||||
"editions": "^1.1.1",
|
||||
|
@ -1305,7 +1305,7 @@
|
|||
},
|
||||
"chalk": {
|
||||
"version": "1.1.3",
|
||||
"resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz",
|
||||
"resolved": "http://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz",
|
||||
"integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=",
|
||||
"requires": {
|
||||
"ansi-styles": "^2.2.1",
|
||||
|
@ -1687,7 +1687,7 @@
|
|||
},
|
||||
"buffer": {
|
||||
"version": "3.6.0",
|
||||
"resolved": "https://registry.npmjs.org/buffer/-/buffer-3.6.0.tgz",
|
||||
"resolved": "http://registry.npmjs.org/buffer/-/buffer-3.6.0.tgz",
|
||||
"integrity": "sha1-pyyTb3e5a/UvX357RnGAYoVR3vs=",
|
||||
"requires": {
|
||||
"base64-js": "0.0.8",
|
||||
|
@ -1986,7 +1986,7 @@
|
|||
},
|
||||
"chalk": {
|
||||
"version": "1.1.3",
|
||||
"resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz",
|
||||
"resolved": "http://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz",
|
||||
"integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=",
|
||||
"requires": {
|
||||
"ansi-styles": "^2.2.1",
|
||||
|
@ -3318,7 +3318,7 @@
|
|||
},
|
||||
"express": {
|
||||
"version": "4.16.3",
|
||||
"resolved": "https://registry.npmjs.org/express/-/express-4.16.3.tgz",
|
||||
"resolved": "http://registry.npmjs.org/express/-/express-4.16.3.tgz",
|
||||
"integrity": "sha1-avilAjUNsyRuzEvs9rWjTSL37VM=",
|
||||
"requires": {
|
||||
"accepts": "~1.3.5",
|
||||
|
@ -3463,14 +3463,14 @@
|
|||
"dependencies": {
|
||||
"typechecker": {
|
||||
"version": "2.0.8",
|
||||
"resolved": "https://registry.npmjs.org/typechecker/-/typechecker-2.0.8.tgz",
|
||||
"resolved": "http://registry.npmjs.org/typechecker/-/typechecker-2.0.8.tgz",
|
||||
"integrity": "sha1-6D2oS7ZMWEzLNFg4V2xAsDN9uC4="
|
||||
}
|
||||
}
|
||||
},
|
||||
"external-editor": {
|
||||
"version": "2.2.0",
|
||||
"resolved": "https://registry.npmjs.org/external-editor/-/external-editor-2.2.0.tgz",
|
||||
"resolved": "http://registry.npmjs.org/external-editor/-/external-editor-2.2.0.tgz",
|
||||
"integrity": "sha512-bSn6gvGxKt+b7+6TKEv1ZycHleA7aHhRHyAqJyp5pbUFuYYNIzpZnQDk7AsYckyWdEnTeAnay0aCy2aV6iTk9A==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
|
@ -3548,7 +3548,7 @@
|
|||
"dependencies": {
|
||||
"typechecker": {
|
||||
"version": "2.0.8",
|
||||
"resolved": "https://registry.npmjs.org/typechecker/-/typechecker-2.0.8.tgz",
|
||||
"resolved": "http://registry.npmjs.org/typechecker/-/typechecker-2.0.8.tgz",
|
||||
"integrity": "sha1-6D2oS7ZMWEzLNFg4V2xAsDN9uC4="
|
||||
}
|
||||
}
|
||||
|
@ -4773,7 +4773,7 @@
|
|||
"dependencies": {
|
||||
"minimist": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
|
||||
"resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
|
||||
"integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ="
|
||||
},
|
||||
"process": {
|
||||
|
@ -4813,7 +4813,7 @@
|
|||
},
|
||||
"http-errors": {
|
||||
"version": "1.6.3",
|
||||
"resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.3.tgz",
|
||||
"resolved": "http://registry.npmjs.org/http-errors/-/http-errors-1.6.3.tgz",
|
||||
"integrity": "sha1-i1VoC7S+KDoLW/TqLjhYC+HZMg0=",
|
||||
"requires": {
|
||||
"depd": "~1.1.2",
|
||||
|
@ -5648,7 +5648,7 @@
|
|||
},
|
||||
"jsonfile": {
|
||||
"version": "2.4.0",
|
||||
"resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-2.4.0.tgz",
|
||||
"resolved": "http://registry.npmjs.org/jsonfile/-/jsonfile-2.4.0.tgz",
|
||||
"integrity": "sha1-NzaitCi4e72gzIO1P6PWM6NcKug=",
|
||||
"requires": {
|
||||
"graceful-fs": "^4.1.6"
|
||||
|
@ -5722,7 +5722,7 @@
|
|||
},
|
||||
"levenshtein-edit-distance": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/levenshtein-edit-distance/-/levenshtein-edit-distance-1.0.0.tgz",
|
||||
"resolved": "http://registry.npmjs.org/levenshtein-edit-distance/-/levenshtein-edit-distance-1.0.0.tgz",
|
||||
"integrity": "sha1-iVuvR4zOi1waDSfkXXwdl4pmHkk="
|
||||
},
|
||||
"levn": {
|
||||
|
@ -6023,7 +6023,7 @@
|
|||
"dependencies": {
|
||||
"minimist": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
|
||||
"resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
|
||||
"integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=",
|
||||
"optional": true
|
||||
}
|
||||
|
@ -6240,7 +6240,7 @@
|
|||
},
|
||||
"minimist": {
|
||||
"version": "0.0.8",
|
||||
"resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",
|
||||
"resolved": "http://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",
|
||||
"integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0="
|
||||
},
|
||||
"minipass": {
|
||||
|
@ -6305,7 +6305,7 @@
|
|||
},
|
||||
"mkdirp": {
|
||||
"version": "0.5.1",
|
||||
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
|
||||
"resolved": "http://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
|
||||
"integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
|
||||
"requires": {
|
||||
"minimist": "0.0.8"
|
||||
|
@ -6339,7 +6339,7 @@
|
|||
"dependencies": {
|
||||
"commander": {
|
||||
"version": "2.15.1",
|
||||
"resolved": "https://registry.npmjs.org/commander/-/commander-2.15.1.tgz",
|
||||
"resolved": "http://registry.npmjs.org/commander/-/commander-2.15.1.tgz",
|
||||
"integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag=="
|
||||
},
|
||||
"glob": {
|
||||
|
@ -6580,7 +6580,7 @@
|
|||
"dependencies": {
|
||||
"minimist": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
|
||||
"resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
|
||||
"integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ="
|
||||
}
|
||||
}
|
||||
|
@ -6705,7 +6705,7 @@
|
|||
},
|
||||
"buffer": {
|
||||
"version": "4.9.1",
|
||||
"resolved": "https://registry.npmjs.org/buffer/-/buffer-4.9.1.tgz",
|
||||
"resolved": "http://registry.npmjs.org/buffer/-/buffer-4.9.1.tgz",
|
||||
"integrity": "sha1-bRu2AbB6TvztlwlBMgkwJ8lbwpg=",
|
||||
"requires": {
|
||||
"base64-js": "^1.0.2",
|
||||
|
@ -6771,7 +6771,7 @@
|
|||
},
|
||||
"chalk": {
|
||||
"version": "0.4.0",
|
||||
"resolved": "https://registry.npmjs.org/chalk/-/chalk-0.4.0.tgz",
|
||||
"resolved": "http://registry.npmjs.org/chalk/-/chalk-0.4.0.tgz",
|
||||
"integrity": "sha1-UZmj3c0MHv4jvAjBsCewYXbgxk8=",
|
||||
"requires": {
|
||||
"ansi-styles": "~1.0.0",
|
||||
|
@ -7384,7 +7384,7 @@
|
|||
},
|
||||
"chalk": {
|
||||
"version": "1.1.3",
|
||||
"resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz",
|
||||
"resolved": "http://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz",
|
||||
"integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=",
|
||||
"requires": {
|
||||
"ansi-styles": "^2.2.1",
|
||||
|
@ -8513,7 +8513,7 @@
|
|||
"dependencies": {
|
||||
"commander": {
|
||||
"version": "2.8.1",
|
||||
"resolved": "https://registry.npmjs.org/commander/-/commander-2.8.1.tgz",
|
||||
"resolved": "http://registry.npmjs.org/commander/-/commander-2.8.1.tgz",
|
||||
"integrity": "sha1-Br42f+v9oMMwqh4qBy09yXYkJdQ=",
|
||||
"requires": {
|
||||
"graceful-readlink": ">= 1.0.0"
|
||||
|
@ -8714,7 +8714,7 @@
|
|||
},
|
||||
"sinon": {
|
||||
"version": "4.5.0",
|
||||
"resolved": "https://registry.npmjs.org/sinon/-/sinon-4.5.0.tgz",
|
||||
"resolved": "http://registry.npmjs.org/sinon/-/sinon-4.5.0.tgz",
|
||||
"integrity": "sha512-trdx+mB0VBBgoYucy6a9L7/jfQOmvGeaKZT4OOJ+lPAtI8623xyGr8wLiE4eojzBS8G9yXbhx42GHUOVLr4X2w==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
|
@ -9503,7 +9503,7 @@
|
|||
},
|
||||
"table": {
|
||||
"version": "4.0.3",
|
||||
"resolved": "https://registry.npmjs.org/table/-/table-4.0.3.tgz",
|
||||
"resolved": "http://registry.npmjs.org/table/-/table-4.0.3.tgz",
|
||||
"integrity": "sha512-S7rnFITmBH1EnyKcvxBh1LjYeQMmnZtCXSEbHcH6S0NoKit24ZuFO/T1vDcLdYsLQkM188PVVhQmzKIuThNkKg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
|
@ -9600,7 +9600,7 @@
|
|||
"dependencies": {
|
||||
"bluebird": {
|
||||
"version": "2.11.0",
|
||||
"resolved": "https://registry.npmjs.org/bluebird/-/bluebird-2.11.0.tgz",
|
||||
"resolved": "http://registry.npmjs.org/bluebird/-/bluebird-2.11.0.tgz",
|
||||
"integrity": "sha1-U0uQM8AiyVecVro7Plpcqvu2UOE="
|
||||
},
|
||||
"mout": {
|
||||
|
@ -9825,7 +9825,7 @@
|
|||
},
|
||||
"typechecker": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/typechecker/-/typechecker-2.1.0.tgz",
|
||||
"resolved": "http://registry.npmjs.org/typechecker/-/typechecker-2.1.0.tgz",
|
||||
"integrity": "sha1-0cIJOlT/ihn1jP+HfuqlTyJC04M="
|
||||
},
|
||||
"typedarray": {
|
||||
|
@ -10795,7 +10795,7 @@
|
|||
},
|
||||
"wrap-ansi": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz",
|
||||
"resolved": "http://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz",
|
||||
"integrity": "sha1-2Pw9KE3QV5T+hJc8rs3Rz4JP3YU=",
|
||||
"requires": {
|
||||
"string-width": "^1.0.1",
|
||||
|
@ -10939,7 +10939,7 @@
|
|||
},
|
||||
"yargs": {
|
||||
"version": "4.8.1",
|
||||
"resolved": "https://registry.npmjs.org/yargs/-/yargs-4.8.1.tgz",
|
||||
"resolved": "http://registry.npmjs.org/yargs/-/yargs-4.8.1.tgz",
|
||||
"integrity": "sha1-wMQpJMpKqmsObaFznfshZDn53cA=",
|
||||
"requires": {
|
||||
"cliui": "^3.2.0",
|
||||
|
@ -10960,7 +10960,7 @@
|
|||
"dependencies": {
|
||||
"os-locale": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/os-locale/-/os-locale-1.4.0.tgz",
|
||||
"resolved": "http://registry.npmjs.org/os-locale/-/os-locale-1.4.0.tgz",
|
||||
"integrity": "sha1-IPnxeuKe00XoveWDsT0gCYA8FNk=",
|
||||
"requires": {
|
||||
"lcid": "^1.0.0"
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
"eth-ens-namehash": "^2.0.8",
|
||||
"eth-lib": "^0.2.8",
|
||||
"ethereumjs-wallet": "0.6.0",
|
||||
"express": "^4.16.3",
|
||||
"file-loader": "^1.1.5",
|
||||
"finalhandler": "^1.1.1",
|
||||
"flatted": "^0.2.3",
|
||||
|
|
Loading…
Reference in New Issue