forked from firefox-devtools/debugger
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmocha-server.js
More file actions
executable file
·67 lines (53 loc) · 1.7 KB
/
Copy pathmocha-server.js
File metadata and controls
executable file
·67 lines (53 loc) · 1.7 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env node
"use strict";
const path = require("path");
const webpack = require("webpack");
const express = require("express");
const projectConfig = require("../webpack.config");
const webpackDevMiddleware = require("webpack-dev-middleware");
const fs = require("fs");
function recursiveReaddirSync(dir) {
let list = [];
const files = fs.readdirSync(dir);
files.forEach(function(file) {
const stats = fs.lstatSync(path.join(dir, file));
if (stats.isDirectory()) {
list = list.concat(recursiveReaddirSync(path.join(dir, file)));
} else {
list.push(path.join(dir, file));
}
});
return list;
}
function getTestPaths(dir) {
const paths = recursiveReaddirSync(dir);
return paths.filter(p => {
const inTestDirectory = path.dirname(p).includes("tests");
const inIntegrationDir = path.dirname(p).includes("integration");
const aHiddenFile = path.basename(p).charAt(0) == ".";
return inTestDirectory && !aHiddenFile && !inIntegrationDir;
});
}
const testPaths = getTestPaths(path.join(__dirname, "../public/js"));
projectConfig.entry.bundle = projectConfig.entry.bundle.concat(testPaths);
const config = Object.assign({}, projectConfig, {});
const app = express();
const compiler = webpack(config);
app.use(express.static("public"));
app.use(express.static("node_modules"));
app.use(webpackDevMiddleware(compiler, {
publicPath: projectConfig.output.publicPath,
noInfo: true,
stats: {
colors: true
}
}));
app.get("/", function(req, res) {
res.sendFile(path.join(__dirname, "../mocha-runner.html"));
});
app.listen(8003, "localhost", function(err, result) {
if (err) {
console.log(err);
}
console.log("Listening at http://localhost:8003");
});