forked from live-codes/livecodes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-i18n-exclude.js
More file actions
32 lines (25 loc) · 992 Bytes
/
Copy pathtest-i18n-exclude.js
File metadata and controls
32 lines (25 loc) · 992 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
// Check all folders under src/livecodes/i18n/locales, ensure no `.ts` files contains a specific comment defined in `i18n-exclude.js`.
const { TS_NOCHECK } = require('./i18n-exclude');
const fs = require('fs');
const path = require('path');
const localesDir = path.resolve('src/livecodes/i18n/locales');
const checkExcluded = () => {
const dirs = fs
.readdirSync(localesDir, { withFileTypes: true })
.filter((dirent) => dirent.isDirectory())
.map((dirent) => path.join(localesDir, dirent.name));
for (const dir of dirs) {
const tsFiles = fs
.readdirSync(dir)
.filter((file) => file.endsWith('.ts'))
.map((file) => path.join(dir, file));
for (const file of tsFiles) {
const content = fs.readFileSync(file, 'utf8');
if (content.includes(TS_NOCHECK)) {
throw new Error(`File ${file} contains the exclusion comment`);
}
}
}
console.log('No files contain the exclusion comment. Test passed.');
};
checkExcluded();