-
Notifications
You must be signed in to change notification settings - Fork 2
/
puppeteer.js
36 lines (31 loc) · 939 Bytes
/
puppeteer.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
const express = require('express');
const serve = require('express-static');
require('http-shutdown').extend();
const app = express();
const root = __dirname + '/dist/' + process.argv[3];
app.use(serve(root));
const server = app.listen(8080, function() {
console.log("Serving content from " + root);
}).withShutdown();
(async () => {
try {
const module = process.argv[2]
console.log('Loading Puppeteer test module:', module);
import('./output-es/' + module + '/index.js').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 shutdown.');
});
}