-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackend.js
39 lines (34 loc) · 823 Bytes
/
backend.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/promises')
const path = require('path')
const letterFiles = {
"moving": [],
"master1": [],
"master2": []
}
fs.readdir('./src/moving')
.then(files => {
for (const file of files) {
if(path.extname(file) === '.js') letterFiles['moving'].push(`./src/moving/${file}`)
}
})
.then(() => {
return fs.readdir('./src/m1src')
})
.then((files) => {
for (const file of files) {
if(path.extname(file) === '.js') letterFiles['master1'].push(`./src/m1src/${file}`)
}
})
.then(() => {
return fs.readdir('./src/m2src')
})
.then((files) => {
for (const file of files) {
if(path.extname(file) === '.js') letterFiles['master2'].push(`./src/m2src/${file}`)
}
})
.then(() => {
fs.writeFile('./data.json', JSON.stringify(letterFiles), (err) => {
if(err) console.log(err)
})
})