chore: simplify code for modules internally using remote.require in sandbox (#16104)

This commit is contained in:
Milan Burda 2018-12-17 20:47:41 +01:00 committed by Alexey Kuzmin
parent c64b4a3926
commit 7a6fe00f49
7 changed files with 8 additions and 49 deletions

View file

@ -9,16 +9,16 @@ exports.getRemote = function (name) {
return remote[name]
}
exports.getRemoteFor = function (usage) {
exports.remoteRequire = function (name) {
if (!remote) {
throw new Error(`${usage} requires remote, which is not enabled`)
throw new Error(`${name} requires remote, which is not enabled`)
}
return remote
return remote.require(name)
}
exports.potentiallyRemoteRequire = function (name) {
if (process.sandboxed) {
return exports.getRemoteFor(name).require(name)
return exports.remoteRequire(name)
} else {
return require(name)
}