-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathget-icon-path.js
More file actions
41 lines (34 loc) · 1.05 KB
/
get-icon-path.js
File metadata and controls
41 lines (34 loc) · 1.05 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
const fs = require('fs')
const hkgmoji = require('./hkgmoji.json')
function appendLine(content) {
fs.appendFile('hkgmoji.js', `${content}\n`, (err) => {
if (err) {
console.log('error writing line', err)
}
})
}
async function init() {
appendLine('const hkgmoji = {')
console.log('[info] Getting hkgmoji.json...')
const allKeys = hkgmoji.reduce((acc, cur) => {
const normalKeys = cur.icons.map(icon => icon[1])
const specialKeys = cur.special ? cur.special.map(icon => icon[1]) : []
return [
...acc,
...normalKeys,
...specialKeys,
]
}, [])
// eslint-disable-next-line
for (let [index, key] of allKeys.entries()) {
const staticKey = key.replace('/faces/', '/faces_png/').replace('.gif', '.png')
appendLine(` '/${key}': require('./${key}'),`)
appendLine(` '/${staticKey}': require('./${staticKey}'),`)
console.log(`[success] [${index + 1}/${allKeys.length}] ${key}`)
}
appendLine('}')
appendLine('')
appendLine('export default hkgmoji')
console.log('[success] All done!')
}
init()