Skip to content

Commit 3f6f5b6

Browse files
committed
fix: snap packages don't follow artifactName
Close #2576
1 parent cebeb44 commit 3f6f5b6

File tree

4 files changed

+14
-9
lines changed

4 files changed

+14
-9
lines changed

packages/electron-builder-lib/src/platformPackager.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -399,12 +399,12 @@ export abstract class PlatformPackager<DC extends PlatformSpecificBuildOptions>
399399
if (ext === "AppImage" || ext === "rpm") {
400400
archName = "x86_64"
401401
}
402-
else if (ext === "deb") {
402+
else if (ext === "deb" || ext === "snap") {
403403
archName = "amd64"
404404
}
405405
}
406406
else if (arch === Arch.ia32) {
407-
if (ext === "deb" || ext === "AppImage") {
407+
if (ext === "deb" || ext === "AppImage" || ext === "snap") {
408408
archName = "i386"
409409
}
410410
else if (ext === "pacman" || ext === "rpm") {

packages/electron-builder-lib/src/targets/snap.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ export default class SnapTarget extends Target {
3030
return result
3131
}
3232

33-
private createDescriptor(snapName: string, arch: Arch): any {
33+
private createDescriptor(arch: Arch): any {
3434
const appInfo = this.packager.appInfo
35+
const snapName = this.packager.executableName.toLowerCase()
3536
const options = this.options
3637
const linuxArchName = toAppImageOrSnapArch(arch)
3738

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

117-
const snap: any = this.createDescriptor(snapName, arch)
118+
const snap: any = this.createDescriptor(arch)
118119
if (this.isUseTemplateApp) {
119120
delete snap.parts
120121
}
@@ -166,7 +167,7 @@ export default class SnapTarget extends Target {
166167
args.push("--template-url", this.packager.isElectron2 ? "electron2" : "electron1")
167168
}
168169
await executeAppBuilder(args)
169-
packager.dispatchArtifactCreated(artifactPath, this, arch)
170+
packager.dispatchArtifactCreated(artifactPath, this, arch, packager.computeSafeArtifactName(artifactName, "snap", arch, false))
170171
}
171172
}
172173

test/out/linux/__snapshots__/snapTest.js.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ Object {
509509
"linux": Array [
510510
Object {
511511
"arch": "x64",
512-
"file": "sep-electron2_1.1.0_amd64.snap",
512+
"file": "sep-electron2_v1.1.0.snap",
513513
},
514514
],
515515
}

test/src/linux/snapTest.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ test.ifAll.ifDevOrLinuxCi("snap electron 2", app({
2525
extraMetadata: {
2626
name: "sep-electron2",
2727
},
28+
linux: {
29+
//tslint:disable-next-line:no-invalid-template-strings
30+
artifactName: "${name}_v${version}.${ext}",
31+
},
2832
productName: "Sep Electron 2",
2933
electronVersion: "2.0.0-beta.1",
3034
},

0 commit comments

Comments
 (0)