forked from electron/electron
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gen-hunspell-filenames.js
35 lines (26 loc) · 1.11 KB
/
gen-hunspell-filenames.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
const fs = require('fs');
const path = require('path');
const check = process.argv.includes('--check');
const dictsPath = path.resolve(__dirname, '..', '..', 'third_party', 'hunspell_dictionaries');
const gclientPath = 'third_party/hunspell_dictionaries';
const allFiles = fs.readdirSync(dictsPath);
const dictionaries = allFiles
.filter(file => path.extname(file) === '.bdic');
const licenses = allFiles
.filter(file => file.startsWith('LICENSE') || file.startsWith('COPYING'));
const content = `hunspell_dictionaries = [
${dictionaries.map(f => `"//${path.posix.join(gclientPath, f)}"`).join(',\n ')},
]
hunspell_licenses = [
${licenses.map(f => `"//${path.posix.join(gclientPath, f)}"`).join(',\n ')},
]
`;
const filenamesPath = path.resolve(__dirname, '..', 'filenames.hunspell.gni');
if (check) {
const currentContent = fs.readFileSync(filenamesPath, 'utf8');
if (currentContent !== content) {
throw new Error('hunspell filenames need to be regenerated, latest generation does not match current file. Please run node gen-hunspell-filenames.js');
}
} else {
fs.writeFileSync(filenamesPath, content);
}