diff --git a/packages/electron-updater/src/AppUpdater.ts b/packages/electron-updater/src/AppUpdater.ts index a4881622cc..e682d9bdb6 100644 --- a/packages/electron-updater/src/AppUpdater.ts +++ b/packages/electron-updater/src/AppUpdater.ts @@ -244,7 +244,7 @@ export abstract class AppUpdater extends EventEmitter { } // noinspection JSUnusedGlobalSymbols - checkForUpdatesAndNotify(): Promise { + checkForUpdatesAndNotify(downloadNotification?: DownloadNotification): Promise { if (!this.isUpdaterActive()) { return Promise.resolve(null) } @@ -262,16 +262,28 @@ export abstract class AppUpdater extends EventEmitter { downloadPromise .then(() => { - new Notification({ - title: "A new update is ready to install", - body: `${this.app.name} version ${it.updateInfo.version} has been downloaded and will be automatically installed on exit` - }).show() + const notificationContent = this.formatDownloadNotification(it.updateInfo.version, this.app.name, downloadNotification); + new Notification(notificationContent).show() }) return it }) } + private formatDownloadNotification(version: string, appName: string, downloadNotification?: DownloadNotification): DownloadNotification { + if (downloadNotification == null) { + downloadNotification = { + title: "A new update is ready to install", + body: `{appName} version {version} has been downloaded and will be automatically installed on exit` + } + } + downloadNotification = { + title: downloadNotification.title.replace("{appName}", appName).replace("{version}", version), + body: downloadNotification.body.replace("{appName}", appName).replace("{version}", version) + } + return downloadNotification; + } + private async isStagingMatch(updateInfo: UpdateInfo): Promise { const rawStagingPercentage = updateInfo.stagingPercentage let stagingPercentage = rawStagingPercentage @@ -665,6 +677,11 @@ export interface DownloadExecutorTask { readonly done?: (event: UpdateDownloadedEvent) => Promise } +export interface DownloadNotification { + body: string + title: string +} + /** @private */ export interface TestOnlyUpdaterOptions { platform: ProviderPlatform