-
Notifications
You must be signed in to change notification settings - Fork 74
/
server.js
31 lines (31 loc) · 1022 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
var express = require('express');
var path = require('path');
var glob = require('glob');
var browserify = require('browserify');
var PORT = process.env.PORT || 4201;
var app = express();
app.get('/test/tmp/test.js', function (req, res, next) {
glob("test/**/*.test.js", {}, function (er, testfiles) {
if (er || !testfiles || testfiles.length === 0) {
console.error('No tests found.');
res.send('500');
} else {
console.log('Found test files:', testfiles);
browserify({ debug: true })
.add(testfiles.map(function(file) {
return path.join(__dirname, file);
}))
.bundle()
.on('error', function(err){
console.error(err.message);
res.status(500).send('console.log("'+err.message+'");');
next();
})
.pipe(res);
}
});
});
app.use(express.static(__dirname));
app.listen(PORT);
console.log('Server is listening on %s', PORT);
console.log('To run the test suite go to https://localhost:%s/test', PORT);