(settings: SettingsType)
| 17 | export let updater: Updater; |
| 18 | |
| 19 | function getUpdateChannel(settings: SettingsType): string { |
| 20 | const updaterConfigPath = path.join(process.resourcesPath!, "app-update.yml"); |
| 21 | const updaterConfig = YAML.parse(readFileSync(updaterConfigPath, { encoding: "utf8" }).toString()); |
| 22 | console.log("Updater config from binary:", updaterConfig); |
| 23 | const updaterChannel: string = updaterConfig.channel ?? "latest"; |
| 24 | const settingsChannel = settings["autoupdate:channel"]; |
| 25 | let retVal = settingsChannel; |
| 26 | |
| 27 | // If the user setting doesn't exist yet, set it to the value of the updater config. |
| 28 | // If the user was previously on the `latest` channel and has downloaded a `beta` version, update their configured channel to `beta` to prevent downgrading. |
| 29 | if (!settingsChannel || (settingsChannel == "latest" && updaterChannel == "beta")) { |
| 30 | console.log("Update channel setting does not exist, setting to value from updater config."); |
| 31 | RpcApi.SetConfigCommand(ElectronWshClient, { "autoupdate:channel": updaterChannel }); |
| 32 | retVal = updaterChannel; |
| 33 | } |
| 34 | console.log("Update channel:", retVal); |
| 35 | return retVal; |
| 36 | } |
| 37 | |
| 38 | export class Updater { |
| 39 | autoCheckInterval: NodeJS.Timeout | null; |
no test coverage detected