Skip to content

Commit 2e7b668

Browse files
committed
fix: Platform-specific build option targets ignored since 15.2.0
Close #1355
1 parent e1dda14 commit 2e7b668

File tree

4 files changed

+40
-1
lines changed

4 files changed

+40
-1
lines changed

packages/electron-builder/src/options/linuxOptions.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,12 @@ export interface LinuxBuildOptions extends PlatformSpecificBuildOptions {
2121
readonly description?: string | null
2222

2323
/**
24-
* 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`.
24+
* Target package type: list of `AppImage`, `snap`, `deb`, `rpm`, `freebsd`, `pacman`, `p5p`, `apk`, `7z`, `zip`, `tar.xz`, `tar.lz`, `tar.gz`, `tar.bz2`, `dir`.
2525
*
2626
* 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).
27+
*
28+
* @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)
29+
* @default AppImage
2730
*/
2831
readonly target?: TargetConfigType
2932

packages/electron-builder/src/targets/targetFactory.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ import { ArchiveTarget } from "./ArchiveTarget"
77
const archiveTargets = new Set(["zip", "7z", "tar.xz", "tar.lz", "tar.gz", "tar.bz2"])
88

99
export function computeArchToTargetNamesMap(raw: Map<Arch, string[]>, options: PlatformSpecificBuildOptions, platform: Platform): Map<Arch, string[]> {
10+
for (const targetNames of raw.values()) {
11+
if (targetNames.length > 0) {
12+
// https://github.com/electron-userland/electron-builder/issues/1355
13+
return raw
14+
}
15+
}
16+
1017
const result = new Map(raw)
1118
const defaultArch = platform === Platform.MAC ? "x64" : process.arch
1219
for (const target of asArray(options.target).map<TargetConfig>(it => typeof it === "string" ? {target: it} : it)) {

test/out/__snapshots__/ExtraBuildTest.js.snap

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ Object {
2727
}
2828
`;
2929

30+
exports[`override targets in the config 1`] = `
31+
Object {
32+
"linux": Array [],
33+
}
34+
`;
35+
3036
exports[`prepackaged 1`] = `
3137
Object {
3238
"linux": Array [],

test/src/ExtraBuildTest.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,29 @@ test.ifAll.ifLinuxOrDevMac("prepackaged", app({
5454
}
5555
}))
5656

57+
test.ifAll.ifLinuxOrDevMac("override targets in the config", app({
58+
targets: linuxDirTarget,
59+
}, {
60+
packed: async (context) => {
61+
await build({
62+
project: context.projectDir,
63+
linux: ["deb"],
64+
config: {
65+
publish: null,
66+
// https://github.com/electron-userland/electron-builder/issues/1355
67+
linux: {
68+
"target": [
69+
"AppImage",
70+
"deb",
71+
"rpm"
72+
],
73+
},
74+
compression: "store"
75+
}
76+
})
77+
}
78+
}))
79+
5780
test.ifAll.ifDevOrLinuxCi("scheme validation", appThrows({
5881
targets: linuxDirTarget,
5982
config: <any>{

0 commit comments

Comments
 (0)