You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
629 B
18 lines
629 B
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)
|
|
|