chore: simplify code for modules internally using remote.require in sandbox (#16104)
This commit is contained in:
parent
c64b4a3926
commit
7a6fe00f49
7 changed files with 8 additions and 49 deletions
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue