UNPKG

1.17 kBJavaScriptView Raw
1const fs = require("fs");
2const path = require("path");
3var reporters = {
4 "landing": {
5 path: "landing"
6 },
7 "spec": {
8 path: "spec"
9 },
10 "dot": {
11 path: "dot"
12 },
13 "min": {
14 path: "min"
15 },
16 "progress": {
17 path: "progress"
18 },
19 "spectrum": {
20 npmname: "mocha-spectrum-reporter",
21 location: ["mocha-spectrum-reporter", "index"]
22 },
23 "nyan": {
24 npmname: "nyanplusreporter",
25 location: ["nyanplusreporter", "src", "nyanPlus"]
26 }
27};
28function lookForReporter(config, nickName) {
29 locationPath = reporters[nickName].location.join(path.sep);
30 var locations = [
31 path.join(__dirname, "..", "..", locationPath),
32 path.join(__dirname, "..", "node_modules", locationPath),
33 path.join(config.path.cwd, "node_modules", locationPath)
34 ]
35 for (var loc of locations) {
36 if (fs.existsSync(loc + ".js")) {
37 reporters[nickName].path = loc
38 }
39 }
40}
41function getReporters(config) {
42 lookForReporter(config, "spectrum");
43 lookForReporter(config, "nyan");
44 return reporters;
45}
46module.exports = {
47 get: getReporters
48}