forked from adamlaska/browser-compat-data
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix.js
More file actions
56 lines (48 loc) · 1.06 KB
/
fix.js
File metadata and controls
56 lines (48 loc) · 1.06 KB
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
49
50
51
52
53
54
55
56
'use strict';
const fs = require('fs');
const path = require('path');
const fixBrowserOrder = require('./fix-browser-order');
const fixFeatureOrder = require('./fix-feature-order');
const format = require('./fix-format');
/**
* @param {string[]} files
*/
function load(...files) {
for (let file of files) {
if (file.indexOf(__dirname) !== 0) {
file = path.resolve(__dirname, '..', file);
}
if (!fs.existsSync(file)) {
console.warn('File not found, skipping:', file);
continue; // Ignore non-existent files
}
if (fs.statSync(file).isFile()) {
if (path.extname(file) === '.json') {
fixBrowserOrder(file);
fixFeatureOrder(file);
}
continue;
}
const subFiles = fs.readdirSync(file).map(subfile => {
return path.join(file, subfile);
});
load(...subFiles);
}
}
if (process.argv[2]) {
load(process.argv[2]);
} else {
load(
'api',
'css',
'html',
'http',
'svg',
'javascript',
'mathml',
'test',
'webdriver',
'webextensions',
);
format();
}