Skip to content

Commit

Permalink
msiWrapped: Normalize target names before checking for NSIS target (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Noah Andrews committed May 8, 2023
1 parent c9d20db commit 60eb555
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .changeset/shiny-jars-fetch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"app-builder-lib": patch
"electron-builder": patch
---

When using the msiWrapped target, allow the nsis target to be capitalized in the configuration file
9 changes: 8 additions & 1 deletion packages/app-builder-lib/src/targets/MsiWrappedTarget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,14 @@ export default class MsiWrappedTarget extends MsiTarget {

const target = config.win.target
const nsisTarget = "nsis"
if (!target.some((t: TargetConfiguration | string) => (typeof t === "string" && t === nsisTarget) || (t as TargetConfiguration).target === nsisTarget)) {
if (
!target
.map((t: TargetConfiguration | string): string => {
const result: string = typeof t === "string" ? t : t.target
return result.toLowerCase().trim()
})
.some(t => t === nsisTarget)
) {
throw new Error("No nsis target found! Please specify an nsis target")
}
}
Expand Down
29 changes: 29 additions & 0 deletions test/snapshots/windows/msiWrappedTest.js.snap
Original file line number Diff line number Diff line change
@@ -1,5 +1,34 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`msiWrapped allows capitalized nsis target 1`] = `
Object {
"win": Array [
Object {
"arch": "x64",
"file": "Test MSI 1.1.0.msi",
"safeArtifactName": "Test-MSI-1.1.0.msi",
},
Object {
"arch": "x64",
"file": "Test MSI Setup 1.1.0.exe",
"safeArtifactName": "Test-MSI-Setup-1.1.0.exe",
"updateInfo": Object {
"sha512": "@sha512",
"size": "@size",
},
},
Object {
"file": "Test MSI Setup 1.1.0.exe.blockmap",
"safeArtifactName": "Test-MSI-Setup-1.1.0.exe.blockmap",
"updateInfo": Object {
"sha512": "@sha512",
"size": "@size",
},
},
],
}
`;

exports[`msiWrapped impersonate no if not provided 1`] = `
Object {
"win": Array [
Expand Down
20 changes: 20 additions & 0 deletions test/src/windows/msiWrappedTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,26 @@ test.ifAll.ifDevOrWinCi(
)
)

test.ifAll.ifDevOrWinCi(
"msiWrapped allows capitalized nsis target",
app(
{
targets: Platform.WINDOWS.createTarget(["msiWrapped", "NSIS"]),
config: {
appId: "build.electron.test.msi.oneClick.perMachine",
extraMetadata: {
// version: "1.0.0",
},
productName: "Test MSI",
win: {
target: ["msiWrapped", "NSIS"],
},
},
},
{}
)
)

test.ifAll.ifDevOrWinCi(
"msiWrapped includes packaged exe",
app({
Expand Down

0 comments on commit 60eb555

Please sign in to comment.