1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00
metamask-extension/development/genStates.js

26 lines
950 B
JavaScript
Raw Normal View History

2016-07-01 03:22:16 +02:00
const fs = require('fs')
const path = require('path')
const promisify = require('pify')
const enLocaleMessages = require('../app/_locales/en/messages.json')
const writeFile = promisify(fs.writeFile)
2016-07-01 03:22:16 +02:00
2018-03-11 22:51:54 +01:00
start().catch(console.error)
2016-07-01 03:22:16 +02:00
2018-03-11 22:51:54 +01:00
async function start () {
const statesPath = path.join(__dirname, 'states')
2018-03-12 03:06:14 +01:00
const stateFilesNames = await promisify(fs.readdir)(statesPath)
2018-03-11 22:51:54 +01:00
const states = {}
await Promise.all(stateFilesNames.map(async (stateFileName) => {
const stateFilePath = path.join(__dirname, 'states', stateFileName)
const state = require(stateFilePath)
2018-03-22 04:39:21 +01:00
state.localeMessages = { en: enLocaleMessages, current: {} }
2018-03-11 22:51:54 +01:00
const stateName = stateFileName.split('.')[0].replace(/-/g, ' ', 'g')
states[stateName] = state
}))
const generatedFileContent = `module.exports = ${JSON.stringify(states)}`
const generatedFilePath = path.join(__dirname, 'states.js')
await writeFile(generatedFilePath, generatedFileContent)
2018-03-11 22:51:54 +01:00
}