-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathwebsite-test.js
40 lines (35 loc) · 1016 Bytes
/
website-test.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
const express = require('express');
const serve = require('express-static');
require('http-shutdown').extend();
const app = express();
const root = process.cwd() + '/dist/' + process.argv[2];
app.use(serve(root));
const server = app.listen(8080, function() {
console.log("Serving content from " + root);
}).withShutdown();
(async () => {
try {
if (process.argv.length == 4) {
module = process.cwd() + process.argv[3];
} else {
module = root + '/test.mjs';
}
console.log('Loading Puppeteer test module:', module);
import(module).then(({ main }) => {
main().then(serverDown);
}).catch(err => {
console.error("Failed to load PureScript output:", err);
});
} catch (error) {
console.error('Error:', error);
}
})();
function serverDown() {
console.log('Shutting down server')
server.shutdown(function(err) {
if (err) {
return console.log('shutdown failed', err.message);
}
console.log('Everything is cleanly shut down.');
});
}