mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
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:
@@ -12,11 +12,7 @@ const {EventEmitter} = require('events')
|
||||
|
||||
Object.setPrototypeOf(App.prototype, EventEmitter.prototype)
|
||||
|
||||
let appPath = null
|
||||
|
||||
Object.assign(app, {
|
||||
getAppPath () { return appPath },
|
||||
setAppPath (path) { appPath = path },
|
||||
setApplicationMenu (menu) {
|
||||
return Menu.setApplicationMenu(menu)
|
||||
},
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user