forked from remy/mit-license
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
60 lines (56 loc) · 1.5 KB
/
test.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
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/env node
const path = require('path');
const fs = require('fs');
const CSS = require('css');
let errored = false;
const users = fs.readdirSync('users');
users.forEach(async user => {
if (user.endsWith('json')) {
if (encodeURIComponent(user) === user) {
fs.readFile(path.join('users', user), 'utf8', async (err, content) => {
if (err) {
errored = true;
console.error(`Unable to read ${user}`);
} else {
try {
const u = JSON.parse(content);
if (!u.locked && !u.copyright) {
errored = true;
console.error(`Copyright not specified in ${user} (${e})`);
}
} catch (e) {
errored = true;
console.error(`Invalid JSON in ${user} (${e})`);
}
}
});
} else {
errored = true;
console.error(`${user} is not URL safe`);
}
} else {
errored = true;
console.error(`${user} is not a json file`);
}
});
const themes = fs.readdirSync('themes');
themes.forEach(async theme => {
if (theme.endsWith('css')) {
fs.readFile(path.join('themes', theme), 'utf8', async (err, content) => {
if (err) {
errored = true;
console.error(`Unable to read ${theme}`);
} else {
try {
CSS.parse(content);
} catch (e) {
errored = true;
console.error(`Invalid CSS in ${theme} (${e})`);
}
}
});
}
});
setTimeout(() => {
if (errored) process.exit(1);
}, 500);