aboutsummaryrefslogblamecommitdiffstats
path: root/development/genStates.js
blob: 39a672ee0509427b9343dbc35b5a0b0776e8d925 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

















                                                                     
const fs = require('fs')
const path = require('path')

const statesPath = path.join(__dirname, 'states')
const stateNames = fs.readdirSync(statesPath)

const states = stateNames.reduce((result, stateFileName) => {
  const statePath = path.join(__dirname, 'states', stateFileName)
  const stateFile = fs.readFileSync(statePath).toString()
  const state = JSON.parse(stateFile)
  result[stateFileName.split('.')[0].replace(/-/g, ' ', 'g')] = state
  return result
}, {})

const result = `module.exports = ${JSON.stringify(states)}`

const statesJsonPath = path.join(__dirname, 'states.js')
fs.writeFileSync(statesJsonPath, result)