Skip to content

Commit

Permalink
fix: Platform-specific build option targets ignored since 15.2.0
Browse files Browse the repository at this point in the history
Close #1355
  • Loading branch information
develar committed Mar 13, 2017
1 parent e1dda14 commit 2e7b668
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/electron-builder/src/options/linuxOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 7 additions & 0 deletions packages/electron-builder/src/targets/targetFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Arch, string[]>, options: PlatformSpecificBuildOptions, platform: Platform): Map<Arch, string[]> {
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<TargetConfig>(it => typeof it === "string" ? {target: it} : it)) {
Expand Down
6 changes: 6 additions & 0 deletions test/out/__snapshots__/ExtraBuildTest.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ Object {
}
`;

exports[`override targets in the config 1`] = `
Object {
"linux": Array [],
}
`;

exports[`prepackaged 1`] = `
Object {
"linux": Array [],
Expand Down
23 changes: 23 additions & 0 deletions test/src/ExtraBuildTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: <any>{
Expand Down

0 comments on commit 2e7b668

Please sign in to comment.