mirror of
https://github.com/electron/electron.git
synced 2026-01-08 23:18:06 -05:00
fix: app.getAppPath() returning default-app path for files or directories without package.json (#18763)
This commit is contained in:
committed by
Alexey Kuzmin
parent
7201845894
commit
79f0c444fd
@@ -85,6 +85,7 @@ function loadApplicationPackage (packagePath: string) {
|
||||
// Override app name and version.
|
||||
packagePath = path.resolve(packagePath)
|
||||
const packageJsonPath = path.join(packagePath, 'package.json')
|
||||
let appPath
|
||||
if (fs.existsSync(packageJsonPath)) {
|
||||
let packageJson
|
||||
try {
|
||||
@@ -102,11 +103,12 @@ function loadApplicationPackage (packagePath: string) {
|
||||
} else if (packageJson.name) {
|
||||
app.name = packageJson.name
|
||||
}
|
||||
app._setDefaultAppPaths(packagePath)
|
||||
appPath = packagePath
|
||||
}
|
||||
|
||||
try {
|
||||
Module._resolveFilename(packagePath, module, true)
|
||||
const filePath = Module._resolveFilename(packagePath, module, true)
|
||||
app._setDefaultAppPaths(appPath || path.dirname(filePath))
|
||||
} catch (e) {
|
||||
showErrorMessage(`Unable to find Electron app at ${packagePath}\n\n${e.message}`)
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user