-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathtest.js
37 lines (31 loc) · 816 Bytes
/
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
const langs = require('mangadex-api/langcodes.json')
const { createInterface } = require('readline')
const fs = require('fs')
const rl = createInterface({
input: process.stdin,
output: process.stdout
})
function getAnswer(question, defaultAnswer) {
return new Promise((resolve) => {
rl.question(question, (answer) => {
if (!answer && defaultAnswer) {
return resolve(defaultAnswer)
}
resolve(answer)
})
})
}
const langEmojis = {}
!(async () => {
for (const [langcode, langname] of Object.entries(langs)) {
const emoji = await getAnswer(
`Enter emoji for [${langcode}] ${langname}:\n`
)
langEmojis[langcode] = emoji
}
await fs.promises.writeFile(
'./config/lang-code-emoji.json',
JSON.stringify(langEmojis)
)
console.log('done')
})()