From 2e7b6680a7cab45b660db71a11c8137b725a90fe Mon Sep 17 00:00:00 2001 From: develar Date: Mon, 13 Mar 2017 09:17:43 +0100 Subject: [PATCH] fix: Platform-specific build option targets ignored since 15.2.0 Close #1355 --- .../src/options/linuxOptions.ts | 5 +++- .../src/targets/targetFactory.ts | 7 ++++++ test/out/__snapshots__/ExtraBuildTest.js.snap | 6 +++++ test/src/ExtraBuildTest.ts | 23 +++++++++++++++++++ 4 files changed, 40 insertions(+), 1 deletion(-) diff --git a/packages/electron-builder/src/options/linuxOptions.ts b/packages/electron-builder/src/options/linuxOptions.ts index f8342a52e61..b54761ecbe4 100644 --- a/packages/electron-builder/src/options/linuxOptions.ts +++ b/packages/electron-builder/src/options/linuxOptions.ts @@ -21,9 +21,12 @@ export interface LinuxBuildOptions extends PlatformSpecificBuildOptions { readonly description?: string | null /** - * Target package type: list of `AppImage`, `snap`, `deb`, `rpm`, `freebsd`, `pacman`, `p5p`, `apk`, `7z`, `zip`, `tar.xz`, `tar.lz`, `tar.gz`, `tar.bz2`, `dir`. Defaults to `AppImage`. + * Target package type: list of `AppImage`, `snap`, `deb`, `rpm`, `freebsd`, `pacman`, `p5p`, `apk`, `7z`, `zip`, `tar.xz`, `tar.lz`, `tar.gz`, `tar.bz2`, `dir`. * * electron-builder [docker image](https://github.com/electron-userland/electron-builder/wiki/Docker) can be used to build Linux targets on any platform. See [Multi platform build](https://github.com/electron-userland/electron-builder/wiki/Multi-Platform-Build). + * + * @see [Please do not put an AppImage into another archive like a .zip or .tar.gz](https://github.com/probonopd/AppImageKit/wiki/Creating-AppImages#common-mistake) + * @default AppImage */ readonly target?: TargetConfigType diff --git a/packages/electron-builder/src/targets/targetFactory.ts b/packages/electron-builder/src/targets/targetFactory.ts index e8454aec6a0..ff558788eaf 100644 --- a/packages/electron-builder/src/targets/targetFactory.ts +++ b/packages/electron-builder/src/targets/targetFactory.ts @@ -7,6 +7,13 @@ import { ArchiveTarget } from "./ArchiveTarget" const archiveTargets = new Set(["zip", "7z", "tar.xz", "tar.lz", "tar.gz", "tar.bz2"]) export function computeArchToTargetNamesMap(raw: Map, options: PlatformSpecificBuildOptions, platform: Platform): Map { + for (const targetNames of raw.values()) { + if (targetNames.length > 0) { + // https://github.com/electron-userland/electron-builder/issues/1355 + return raw + } + } + const result = new Map(raw) const defaultArch = platform === Platform.MAC ? "x64" : process.arch for (const target of asArray(options.target).map(it => typeof it === "string" ? {target: it} : it)) { diff --git a/test/out/__snapshots__/ExtraBuildTest.js.snap b/test/out/__snapshots__/ExtraBuildTest.js.snap index 0aa3d858899..0e6ae98e687 100644 --- a/test/out/__snapshots__/ExtraBuildTest.js.snap +++ b/test/out/__snapshots__/ExtraBuildTest.js.snap @@ -27,6 +27,12 @@ Object { } `; +exports[`override targets in the config 1`] = ` +Object { + "linux": Array [], +} +`; + exports[`prepackaged 1`] = ` Object { "linux": Array [], diff --git a/test/src/ExtraBuildTest.ts b/test/src/ExtraBuildTest.ts index 692b3c3f053..ed22d88a5a5 100644 --- a/test/src/ExtraBuildTest.ts +++ b/test/src/ExtraBuildTest.ts @@ -54,6 +54,29 @@ test.ifAll.ifLinuxOrDevMac("prepackaged", app({ } })) +test.ifAll.ifLinuxOrDevMac("override targets in the config", app({ + targets: linuxDirTarget, +}, { + packed: async (context) => { + await build({ + project: context.projectDir, + linux: ["deb"], + config: { + publish: null, + // https://github.com/electron-userland/electron-builder/issues/1355 + linux: { + "target": [ + "AppImage", + "deb", + "rpm" + ], + }, + compression: "store" + } + }) + } +})) + test.ifAll.ifDevOrLinuxCi("scheme validation", appThrows({ targets: linuxDirTarget, config: {