-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.js
More file actions
28 lines (25 loc) · 768 Bytes
/
utils.js
File metadata and controls
28 lines (25 loc) · 768 Bytes
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
const fs = require('fs')
const confs = Object.values(require('./roadData').roadTypes)
function getRoadParts() {
return new Promise((resolve, reject) => {
fs.readdir('./models/road',(err, files) => {
if (err) return reject(err)
const models = files.filter(file => !file.endsWith('.txt')).map(file => {
const name = file.slice(0,-4)
const roadPart = {
url: '/model/road/'+file,
name
}
confs.forEach(conf => {
if (conf.for.includes(name)) {
roadPart.directions = conf.directions
}
})
return roadPart
})
resolve(models)
})})
}
module.exports = {
getRoadParts
}