Skip to content

Commit

Permalink
fix: When error code is ENOENT, try to use electron.shell.openPath
Browse files Browse the repository at this point in the history
…to open Windows installer (#7767)
  • Loading branch information
jackple authored Sep 13, 2023
1 parent b13f60b commit 21f3069
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .changeset/few-eagles-learn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"electron-updater": patch
---


fix: When error code is ENOENT, try to use electron.shell.openPath to run installer on Windows
8 changes: 7 additions & 1 deletion packages/electron-updater/src/NsisUpdater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,15 @@ export class NsisUpdater extends BaseUpdater {
// https://github.com/electron-userland/electron-builder/issues/1129
// Node 8 sends errors: https://nodejs.org/dist/latest-v8.x/docs/api/errors.html#errors_common_system_errors
const errorCode = (e as NodeJS.ErrnoException).code
this._logger.info(`Cannot run installer: error code: ${errorCode}, error message: "${e.message}", will be executed again using elevate if EACCES"`)
this._logger.info(
`Cannot run installer: error code: ${errorCode}, error message: "${e.message}", will be executed again using elevate if EACCES, and will try to use electron.shell.openItem if ENOENT`
)
if (errorCode === "UNKNOWN" || errorCode === "EACCES") {
callUsingElevation()
} else if (errorCode === "ENOENT") {
require("electron")
.shell.openPath(options.installerPath)
.catch((err: Error) => this.dispatchError(err))
} else {
this.dispatchError(e)
}
Expand Down

0 comments on commit 21f3069

Please sign in to comment.