Skip to content

Commit

Permalink
fix: snap packages don't follow artifactName
Browse files Browse the repository at this point in the history
Close #2576
  • Loading branch information
develar committed Mar 6, 2018
1 parent cebeb44 commit 3f6f5b6
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
4 changes: 2 additions & 2 deletions packages/electron-builder-lib/src/platformPackager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -399,12 +399,12 @@ export abstract class PlatformPackager<DC extends PlatformSpecificBuildOptions>
if (ext === "AppImage" || ext === "rpm") {
archName = "x86_64"
}
else if (ext === "deb") {
else if (ext === "deb" || ext === "snap") {
archName = "amd64"
}
}
else if (arch === Arch.ia32) {
if (ext === "deb" || ext === "AppImage") {
if (ext === "deb" || ext === "AppImage" || ext === "snap") {
archName = "i386"
}
else if (ext === "pacman" || ext === "rpm") {
Expand Down
13 changes: 7 additions & 6 deletions packages/electron-builder-lib/src/targets/snap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ export default class SnapTarget extends Target {
return result
}

private createDescriptor(snapName: string, arch: Arch): any {
private createDescriptor(arch: Arch): any {
const appInfo = this.packager.appInfo
const snapName = this.packager.executableName.toLowerCase()
const options = this.options
const linuxArchName = toAppImageOrSnapArch(arch)

Expand Down Expand Up @@ -109,12 +110,12 @@ export default class SnapTarget extends Target {
async build(appOutDir: string, arch: Arch): Promise<any> {
const packager = this.packager
const options = this.options
const snapName = packager.executableName.toLowerCase()
const snapFileName = `${snapName}_${packager.appInfo.version}_${toLinuxArchString(arch)}.snap`
const artifactPath = path.join(this.outDir, snapFileName)
// tslint:disable-next-line:no-invalid-template-strings
const artifactName = packager.expandArtifactNamePattern(this.options, "snap", arch, "${name}_${version}_${arch}.${ext}", false)
const artifactPath = path.join(this.outDir, artifactName)
this.logBuilding("snap", artifactPath, arch)

const snap: any = this.createDescriptor(snapName, arch)
const snap: any = this.createDescriptor(arch)
if (this.isUseTemplateApp) {
delete snap.parts
}
Expand Down Expand Up @@ -166,7 +167,7 @@ export default class SnapTarget extends Target {
args.push("--template-url", this.packager.isElectron2 ? "electron2" : "electron1")
}
await executeAppBuilder(args)
packager.dispatchArtifactCreated(artifactPath, this, arch)
packager.dispatchArtifactCreated(artifactPath, this, arch, packager.computeSafeArtifactName(artifactName, "snap", arch, false))
}
}

Expand Down
2 changes: 1 addition & 1 deletion test/out/linux/__snapshots__/snapTest.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ Object {
"linux": Array [
Object {
"arch": "x64",
"file": "sep-electron2_1.1.0_amd64.snap",
"file": "sep-electron2_v1.1.0.snap",
},
],
}
Expand Down
4 changes: 4 additions & 0 deletions test/src/linux/snapTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ test.ifAll.ifDevOrLinuxCi("snap electron 2", app({
extraMetadata: {
name: "sep-electron2",
},
linux: {
//tslint:disable-next-line:no-invalid-template-strings
artifactName: "${name}_v${version}.${ext}",
},
productName: "Sep Electron 2",
electronVersion: "2.0.0-beta.1",
},
Expand Down

0 comments on commit 3f6f5b6

Please sign in to comment.