diff --git a/packages/electron-builder/src/fileMatcher.ts b/packages/electron-builder/src/fileMatcher.ts index 926e9037024..fc793361e41 100644 --- a/packages/electron-builder/src/fileMatcher.ts +++ b/packages/electron-builder/src/fileMatcher.ts @@ -74,7 +74,7 @@ export class FileMatcher { private expandPattern(pattern: string): string { return pattern - .replace(/\$\{arch}/g, this.options.arch) + .replace(/\$\{arch}/g, this.options.arch!) .replace(/\$\{os}/g, this.options.os) .replace(/\$\{\/\*}/g, "{,/**/*}") } diff --git a/packages/electron-builder/src/metadata.ts b/packages/electron-builder/src/metadata.ts index 9184a86efe2..5eed600799a 100755 --- a/packages/electron-builder/src/metadata.ts +++ b/packages/electron-builder/src/metadata.ts @@ -343,7 +343,7 @@ export interface PlatformSpecificBuildOptions extends TargetSpecificOptions { export interface Macros { os: string - arch: string + arch: string | null } export function getPlatformIconFileName(value: string | null | undefined, isMac: boolean) { diff --git a/packages/electron-builder/src/publish/PublishManager.ts b/packages/electron-builder/src/publish/PublishManager.ts index d5901c1f257..d937c93a95d 100644 --- a/packages/electron-builder/src/publish/PublishManager.ts +++ b/packages/electron-builder/src/publish/PublishManager.ts @@ -75,7 +75,7 @@ export class PublishManager implements PublishContext { let publishConfig = publishConfigs[0] if ((publishConfig).url != null) { - publishConfig = Object.assign({}, publishConfig, {url: expandPattern((publishConfig).url, {os: packager.platform.buildConfigurationKey, arch: Arch[Arch.x64]})}) + publishConfig = Object.assign({}, publishConfig, {url: expandPattern((publishConfig).url, {os: packager.platform.buildConfigurationKey, arch: packager.platform === Platform.WINDOWS ? null : Arch[Arch.x64]})}) } if (packager.platform === Platform.WINDOWS) { @@ -322,9 +322,21 @@ export function computeDownloadUrl(publishConfig: PublishConfiguration, fileName } function expandPattern(pattern: string, macros: Macros): string { + const arch = macros.arch + if (arch == null) { + pattern = pattern + .replace("-${arch}", "") + .replace(" ${arch}", "") + .replace("_${arch}", "") + .replace("/${arch}", "") + } + + pattern = pattern.replace(/\$\{os}/g, macros.os) + if (arch != null) { + pattern = pattern.replace(/\$\{arch}/g, arch) + } + return pattern - .replace(/\$\{os}/g, macros.os) - .replace(/\$\{arch}/g, macros.arch) } export function getPublishConfigs(packager: PlatformPackager, targetSpecificOptions: PlatformSpecificBuildOptions | null | undefined, errorIfCannot: boolean): Promise> | null { diff --git a/test/out/windows/__snapshots__/oneClickInstallerTest.js.snap b/test/out/windows/__snapshots__/oneClickInstallerTest.js.snap index 0a463ab2e54..1bb5b9359e4 100644 --- a/test/out/windows/__snapshots__/oneClickInstallerTest.js.snap +++ b/test/out/windows/__snapshots__/oneClickInstallerTest.js.snap @@ -74,7 +74,7 @@ Array [ exports[`perMachine, no run after finish 3`] = ` Object { "provider": "generic", - "url": "https://develar.s3.amazonaws.com/test/win/x64", + "url": "https://develar.s3.amazonaws.com/test/win", } `; diff --git a/test/src/BuildTest.ts b/test/src/BuildTest.ts index e910655a01b..5a3752de793 100644 --- a/test/src/BuildTest.ts +++ b/test/src/BuildTest.ts @@ -133,7 +133,9 @@ test.ifDevOrLinuxCi("electron version from build", app({ }) })) -test("www as default dir", appTwo(Platform.current().createTarget(DIR_TARGET), { +test("www as default dir", appTwo({ + targets: Platform.current().createTarget(DIR_TARGET), +}, { projectDirCreated: projectDir => move(path.join(projectDir, "app"), path.join(projectDir, "www")) }))