-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.js
32 lines (28 loc) · 1.1 KB
/
build.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
const fs = require('fs')
const path = require('path')
const toml = require('toml')
const loopFetch = require('./lib/loopfetch-gtfs')
const modjs = fs.createWriteStream('./module.js')
const tomlConfig = fs.readFileSync(path.resolve(__dirname, 'config.toml'), 'utf8')
const data = toml.parse(tomlConfig)
modjs.on('open', () => {
console.log('Building module.js...')
modjs.write(`/* eslint-disable */\n// THIS IS AN AUTO-GENERATED FILE, DO NOT MANUALLY MODIFY\n\n`)
modjs.write(`module.exports = `)
const prettyjson = require('./lib/format-json')(data)
modjs.write(prettyjson)
modjs.close()
console.log('Built module.js')
})
const routesJS = fs.createWriteStream('./routes.js')
const gtfsMap = data.GTFSPlaces
routesJS.on('open', async () => {
console.log('Building routes.js...')
const routeMap = await loopFetch(gtfsMap)
routesJS.write(`/* eslint-disable */\n// THIS IS AN AUTO-GENERATED FILE, DO NOT MANUALLY MODIFY\n\n`)
routesJS.write(`module.exports = `)
const prettyjson = require('./lib/format-json')(routeMap)
routesJS.write(prettyjson)
routesJS.close()
console.log('Built routes.js')
})