Merge pull request #9095 from seanchas116/better-path-resolve
Search for module from app path when URL is not file protocol
This commit is contained in:
commit
a004cada7c
8 changed files with 59 additions and 4 deletions
|
@ -56,6 +56,7 @@ electron.ipcRenderer.on('ELECTRON_INTERNAL_RENDERER_ASYNC_WEB_FRAME_METHOD', (ev
|
|||
let nodeIntegration = 'false'
|
||||
let preloadScript = null
|
||||
let isBackgroundPage = false
|
||||
let appPath = null
|
||||
for (let arg of process.argv) {
|
||||
if (arg.indexOf('--guest-instance-id=') === 0) {
|
||||
// This is a guest web view.
|
||||
|
@ -69,6 +70,8 @@ for (let arg of process.argv) {
|
|||
preloadScript = arg.substr(arg.indexOf('=') + 1)
|
||||
} else if (arg === '--background-page') {
|
||||
isBackgroundPage = true
|
||||
} else if (arg.indexOf('--app-path=') === 0) {
|
||||
appPath = arg.substr(arg.indexOf('=') + 1)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -116,6 +119,11 @@ if (nodeIntegration === 'true') {
|
|||
} else {
|
||||
global.__filename = __filename
|
||||
global.__dirname = __dirname
|
||||
|
||||
if (appPath) {
|
||||
// Search for module under the app directory
|
||||
module.paths = module.paths.concat(Module._nodeModulePaths(appPath))
|
||||
}
|
||||
}
|
||||
|
||||
// Redirect window.onerror to uncaughtException.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue