forked from mdn/browser-compat-data
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
47 lines (40 loc) · 982 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
43
44
45
46
47
'use strict';
const fs = require('fs');
const path = require('path');
const extend = require('extend');
function load() {
// Recursively load one or more directories passed as arguments.
let dir, result = {};
function processFilename(fn) {
const 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',
'browsers',
'css',
'html',
'http',
'javascript',
'mathml',
'svg',
'webdriver',
'webextensions',
'xpath',
'xslt',
);