forked from mdn/browser-compat-data
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
35 lines (28 loc) · 862 Bytes
/
index.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
var fs = require('fs'),
path = require('path'),
extend = require('extend');
function load() {
// Recursively load one or more directories passed as arguments.
var dir, result = {};
function processFilename(fn) {
var fp = path.join(dir, fn),
// If the given filename is a directory, recursively load it.
extra = fs.statSync(fp).isDirectory() ? load(fp) : require(fp);
// The JSON data is independent of the actual file
// hierarchy, so it is essential to extend "deeply".
result = extend(true, result, extra);
}
for (dir of arguments) {
dir = path.resolve(__dirname, dir);
fs.readdirSync(dir).forEach(processFilename);
}
return result;
}
module.exports = load(
'api',
'css',
'html',
'http',
'javascript',
'webextensions'
);