Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

actually set lzo as default & add tests #2

Merged
merged 4 commits into from
Dec 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/app-builder-lib/src/options/SnapOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ export interface SnapOptions extends CommonLinuxOptions, TargetSpecificOptions {
readonly title?: string | null

/**
* Sets the compression type for the snap. Can be xz or lzo. Defaults to xz when not specified.
* Sets the compression type for the snap. Can be xz or lzo. Defaults to lzo when not specified.
* @default lzo
*/
readonly compression?: "xz" | "lzo" | null
}
Expand Down
7 changes: 4 additions & 3 deletions packages/app-builder-lib/src/targets/snap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,10 @@ export default class SnapTarget extends Target {
}
}

if (snap.compression != null) {
args.push("--compression", snap.compression)
}

if (packager.packagerOptions.effectiveOptionComputed != null && (await packager.packagerOptions.effectiveOptionComputed({ snap, desktopFile, args }))) {
return
}
Expand All @@ -223,9 +227,6 @@ export default class SnapTarget extends Target {
args.push("--template-url", `electron4:${snapArch}`)
}

if (options.compression != null) {
args.push("--compression", options.compression)
}
await executeAppBuilder(args)

await packager.info.callArtifactBuildCompleted({
Expand Down
1 change: 1 addition & 0 deletions packages/app-builder-lib/templates/snap/snapcraft.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
base: core18
grade: stable
confinement: strict
compression: lzo
parts:
launch-scripts:
plugin: dump
Expand Down
41 changes: 41 additions & 0 deletions test/src/linux/snapTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,3 +255,44 @@ test.ifAll.ifDevOrLinuxCi(
},
})
)

test.ifDevOrLinuxCi(
"default compression",
app({
targets: snapTarget,
config: {
extraMetadata: {
name: "sep",
},
productName: "Sep",
},
effectiveOptionComputed: async ({ snap, args }) => {
expect(snap).toMatchSnapshot()
expect(snap.compression).toEqual("lzo")
expect(args).toEqual(expect.arrayContaining(["--compression", "lzo"]))
return true
},
})
)

test.ifDevOrLinuxCi(
"compression option",
app({
targets: snapTarget,
config: {
extraMetadata: {
name: "sep",
},
productName: "Sep",
snap: {
compression: "xz"
}
},
effectiveOptionComputed: async ({ snap, args }) => {
expect(snap).toMatchSnapshot()
expect(snap.compression).toEqual("xz")
expect(args).toEqual(expect.arrayContaining(["--compression", "xz"]))
return true
},
})
)