forked from mdn/browser-compat-data
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
42 lines (34 loc) · 952 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
36
37
38
39
40
41
42
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) {
let fp = path.join(dir, fn);
let extra;
// If the given filename is a directory, recursively load it.
if (fs.statSync(fp).isDirectory()) {
extra = load(fp);
} else if (path.extname(fp) === '.json') {
extra = 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'
);
module.exports.browsers = require('./browsers/browsers.json');