mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-29 15:50:28 +01:00
92971d3c87
* Update eslint-plugin-import version * Convert JS files to use ESM * Update ESLint rules to check imports * Fix test:unit:global command env * Cleanup mock-dev script
28 lines
998 B
JavaScript
28 lines
998 B
JavaScript
/* eslint-disable import/no-dynamic-require */
|
|
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)
|
|
|
|
start().catch(console.error)
|
|
|
|
async function start () {
|
|
const statesPath = path.join(__dirname, 'states')
|
|
const stateFilesNames = await promisify(fs.readdir)(statesPath)
|
|
const states = {}
|
|
await Promise.all(stateFilesNames.map(async (stateFileName) => {
|
|
const stateFilePath = path.join(__dirname, 'states', stateFileName)
|
|
const state = require(stateFilePath)
|
|
|
|
state.localeMessages = { en: enLocaleMessages, current: {} }
|
|
|
|
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)
|
|
}
|