-
Notifications
You must be signed in to change notification settings - Fork 446
/
server.js
42 lines (38 loc) · 985 Bytes
/
server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
var express = require("express");
var app = express();
// Exports
module.exports = {
coverage: coverage
};
function listen(serverPort, launchWindow, cb) {
return app.listen(serverPort, function() {
if (cb) {
cb();
}
if (launchWindow) {
require("child_process").exec("open http://localhost:" + serverPort);
}
});
}
function coverage(serverPort, launchWindow) {
app.use(express.static("coverage/lcov-report"));
return listen(serverPort, launchWindow);
}
// Run if main
if (require.main === module) {
var port = process.argv[2] || 8080;
var run = process.argv[3];
switch (run) {
case "examples":
app.use(express.static("."));
app.get("/500", function(req, res) {
res.send(500);
});
listen(port, true);
break;
case "coverage":
default:
coverage(port, true);
break;
}
}