diff --git a/.changeset/five-worms-work.md b/.changeset/five-worms-work.md new file mode 100644 index 00000000000..3292defb205 --- /dev/null +++ b/.changeset/five-worms-work.md @@ -0,0 +1,5 @@ +--- +"electron-updater": patch +--- + +fix(electron-updater): workaround vite's process.env.\* replacement diff --git a/packages/electron-updater/src/AppAdapter.ts b/packages/electron-updater/src/AppAdapter.ts index 2988024766f..df7b2376f4d 100644 --- a/packages/electron-updater/src/AppAdapter.ts +++ b/packages/electron-updater/src/AppAdapter.ts @@ -34,11 +34,11 @@ export function getAppCacheDir() { // https://github.com/electron/electron/issues/1404#issuecomment-194391247 let result: string if (process.platform === "win32") { - result = process.env.LOCALAPPDATA || path.join(homedir, "AppData", "Local") + result = process.env["LOCALAPPDATA"] || path.join(homedir, "AppData", "Local") } else if (process.platform === "darwin") { result = path.join(homedir, "Library", "Application Support", "Caches") } else { - result = process.env.XDG_CACHE_HOME || path.join(homedir, ".cache") + result = process.env["XDG_CACHE_HOME"] || path.join(homedir, ".cache") } return result } diff --git a/packages/electron-updater/src/AppImageUpdater.ts b/packages/electron-updater/src/AppImageUpdater.ts index e23f871d409..0057bb211f3 100644 --- a/packages/electron-updater/src/AppImageUpdater.ts +++ b/packages/electron-updater/src/AppImageUpdater.ts @@ -16,8 +16,8 @@ export class AppImageUpdater extends BaseUpdater { } public isUpdaterActive(): boolean { - if (process.env.APPIMAGE == null) { - if (process.env.SNAP == null) { + if (process.env["APPIMAGE"] == null) { + if (process.env["SNAP"] == null) { this._logger.warn("APPIMAGE env is not defined, current application is not an AppImage") } else { this._logger.info("SNAP env is defined, updater is disabled") @@ -36,7 +36,7 @@ export class AppImageUpdater extends BaseUpdater { fileInfo, downloadUpdateOptions, task: async (updateFile, downloadOptions) => { - const oldFile = process.env.APPIMAGE! + const oldFile = process.env["APPIMAGE"]! if (oldFile == null) { throw newError("APPIMAGE env is not defined", "ERR_UPDATER_OLD_FILE_NOT_FOUND") } @@ -74,7 +74,7 @@ export class AppImageUpdater extends BaseUpdater { } protected doInstall(options: InstallOptions): boolean { - const appImageFile = process.env.APPIMAGE! + const appImageFile = process.env["APPIMAGE"]! if (appImageFile == null) { throw newError("APPIMAGE env is not defined", "ERR_UPDATER_OLD_FILE_NOT_FOUND") } diff --git a/packages/electron-updater/src/differentialDownloader/downloadPlanBuilder.ts b/packages/electron-updater/src/differentialDownloader/downloadPlanBuilder.ts index d3dbda81ad8..7669aa3e7f7 100644 --- a/packages/electron-updater/src/differentialDownloader/downloadPlanBuilder.ts +++ b/packages/electron-updater/src/differentialDownloader/downloadPlanBuilder.ts @@ -87,7 +87,7 @@ export function computeOperations(oldBlockMap: BlockMap, newBlockMap: BlockMap, return operations } -const isValidateOperationRange = process.env.DIFFERENTIAL_DOWNLOAD_PLAN_BUILDER_VALIDATE_RANGES === "true" +const isValidateOperationRange = process.env["DIFFERENTIAL_DOWNLOAD_PLAN_BUILDER_VALIDATE_RANGES"] === "true" function validateAndAdd(operation: Operation, operations: Array, checksum: string, index: number): void { if (isValidateOperationRange && operations.length !== 0) { diff --git a/packages/electron-updater/src/providerFactory.ts b/packages/electron-updater/src/providerFactory.ts index 4bebe354055..1e8cdf4727b 100644 --- a/packages/electron-updater/src/providerFactory.ts +++ b/packages/electron-updater/src/providerFactory.ts @@ -30,7 +30,7 @@ export function createClient(data: PublishConfiguration | AllPublishOptions, upd switch (provider) { case "github": { const githubOptions = data as GithubOptions - const token = (githubOptions.private ? process.env.GH_TOKEN || process.env.GITHUB_TOKEN : null) || githubOptions.token + const token = (githubOptions.private ? process.env["GH_TOKEN"] || process.env["GITHUB_TOKEN"] : null) || githubOptions.token if (token == null) { return new GitHubProvider(githubOptions, updater, runtimeOptions) } else { diff --git a/packages/electron-updater/src/providers/Provider.ts b/packages/electron-updater/src/providers/Provider.ts index f8f9ee09752..4a51527d033 100644 --- a/packages/electron-updater/src/providers/Provider.ts +++ b/packages/electron-updater/src/providers/Provider.ts @@ -28,7 +28,7 @@ export abstract class Provider { private getChannelFilePrefix(): string { if (this.runtimeOptions.platform === "linux") { - const arch = process.env.TEST_UPDATER_ARCH || process.arch + const arch = process.env["TEST_UPDATER_ARCH"] || process.arch const archSuffix = arch === "x64" ? "" : `-${arch}` return "-linux" + archSuffix } else {