Skip to content

Commit

Permalink
Don't require dolm/tools
Browse files Browse the repository at this point in the history
  • Loading branch information
yishn committed Mar 11, 2020
1 parent 7481ae5 commit 9607290
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ const {ipcMain, remote} = require('electron')
const {readFileSync} = require('fs')
const path = require('path')
const {load: dolmLoad, getKey: dolmGetKey} = require('dolm')
const {safeModuleEval} = nativeRequire('dolm/tools')

const isElectron = process.versions.electron != null
const isRenderer = isElectron && remote != null
Expand Down Expand Up @@ -47,7 +46,18 @@ exports.loadFile = function(filename) {
}

try {
loadStrings(safeModuleEval(readFileSync(filename, 'utf8')))
loadStrings(
Function(`
"use strict"
let exports = {}
let module = {exports}
;(() => (${readFileSync(filename, 'utf8')}))()
return exports
`)()
)
} catch (err) {
loadStrings({})
}
Expand Down

0 comments on commit 9607290

Please sign in to comment.