forked from EddieHubCommunity/BioDrop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate.js
25 lines (22 loc) · 684 Bytes
/
generate.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
const path = require('path')
const fs = require('fs')
// load json files
const readDirectoryPath = path.join(__dirname, 'public', 'data')
const files = fs.readdirSync(readDirectoryPath)
const profiles = files.map((file) => {
const data = JSON.parse(
fs.readFileSync(`${path.join(__dirname, 'public', 'data', file)}`, 'utf8'),
)
return {
username: file.split('.')[0],
...data,
}
})
// generate list file
const writeDirectoryPath = path.join(__dirname, 'public', 'list.json')
const output = profiles.map((profile) => ({
name: profile.name,
username: profile.username,
avatar: profile.avatar,
}))
fs.writeFileSync(writeDirectoryPath, JSON.stringify(output))