forked from errorception/errorception-hooks
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
21 lines (17 loc) · 729 Bytes
/
index.js
File metadata and controls
21 lines (17 loc) · 729 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
var fs = require("fs"),
path = require("path"),
marked = require("marked");
var files = fs.readdirSync(path.join(__dirname, "hooks"));
var hooksDir = path.join(__dirname, "hooks");
files.filter(function(file) {
return fs.statSync(path.join(hooksDir, file)).isDirectory()
&& fs.statSync(path.join(hooksDir, file, "index.js")).isFile();
}).forEach(function(hookName) {
exports[hookName] = require("./hooks/" + hookName + "/index.js");
exports[hookName].name = hookName;
if(fs.existsSync(path.join(hooksDir, hookName, "README.md"))) {
exports[hookName].docs = marked(fs.readFileSync(path.join(hooksDir, hookName, "README.md"), "utf8"));
} else {
console.warn("The", hookName, "hook doesn't have any docs!");
}
});