forked from adamlaska/browser-compat-data
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenumerate-features.js
More file actions
48 lines (38 loc) · 972 Bytes
/
enumerate-features.js
File metadata and controls
48 lines (38 loc) · 972 Bytes
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
48
const yargs = require('yargs');
const fs = require('fs');
const path = require('path');
const { walk } = require('../utils');
function main({ dest, dataFrom }) {
fs.writeFileSync(dest, JSON.stringify(enumerateFeatures(dataFrom)));
}
function enumerateFeatures(dataFrom) {
const feats = [];
const walker = dataFrom
? walk(undefined, require(path.join(process.cwd(), dataFrom)))
: walk();
for (const { path, compat } of walker) {
if (compat) {
feats.push(path);
}
}
return feats;
}
const { argv } = yargs.command(
'$0 [dest]',
'Write a JSON-formatted list of feature paths',
yargs => {
yargs
.positional('dest', {
default: '.features.json',
description: 'File destination',
})
.option('data-from', {
nargs: 1,
description: 'Require compat data from an alternate path',
});
},
);
if (require.main === module) {
main(argv);
}
module.exports = enumerateFeatures;