forked from InjectiveLabs/injective-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate.cjs
35 lines (28 loc) · 845 Bytes
/
generate.cjs
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 { join } = require('node:path')
const { readdirSync, writeFileSync } = require('node:fs')
function getDirectoryFileNames(folderPath, prefix) {
let list = []
const path = join(__dirname, '../', folderPath)
readdirSync(path).forEach((fileName) => {
if (!fileName.endsWith('.vue')) {
const subList = getDirectoryFileNames(
`${folderPath}/${fileName}`,
fileName
)
list = [...list, ...subList]
} else {
const fileNameWithPrefix = prefix ? `${prefix}/${fileName}` : fileName
list.push(fileNameWithPrefix.replace('.vue', ''))
}
})
return list
}
function writeDataToFile() {
try {
const icons = getDirectoryFileNames('lib/icons')
writeFileSync('icons.json', JSON.stringify({ icons }, null, '\t'))
} catch (err) {
console.error(err)
}
}
writeDataToFile()