1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-22 09:57:02 +01:00

Speed up genStates script by using built-in require fn

This commit is contained in:
Whymarrh Whitby 2018-11-19 13:34:32 -03:30
parent f1248ac26a
commit 5dc87b6835

View File

@ -2,7 +2,7 @@ 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)
@ -12,8 +12,7 @@ async function start () {
const states = {}
await Promise.all(stateFilesNames.map(async (stateFileName) => {
const stateFilePath = path.join(__dirname, 'states', stateFileName)
const stateFileContent = await promisify(fs.readFile)(stateFilePath, 'utf8')
const state = JSON.parse(stateFileContent)
const state = require(stateFilePath)
state.localeMessages = { en: enLocaleMessages, current: {} }
@ -22,5 +21,5 @@ async function start () {
}))
const generatedFileContent = `module.exports = ${JSON.stringify(states)}`
const generatedFilePath = path.join(__dirname, 'states.js')
await promisify(fs.writeFile)(generatedFilePath, generatedFileContent)
await writeFile(generatedFilePath, generatedFileContent)
}