Skip to content

Commit 60eb555

Browse files
author
Noah Andrews
authored
msiWrapped: Normalize target names before checking for NSIS target (#7529)
1 parent c9d20db commit 60eb555

File tree

4 files changed

+63
-1
lines changed

4 files changed

+63
-1
lines changed

.changeset/shiny-jars-fetch.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"app-builder-lib": patch
3+
"electron-builder": patch
4+
---
5+
6+
When using the msiWrapped target, allow the nsis target to be capitalized in the configuration file

packages/app-builder-lib/src/targets/MsiWrappedTarget.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,14 @@ export default class MsiWrappedTarget extends MsiTarget {
3838

3939
const target = config.win.target
4040
const nsisTarget = "nsis"
41-
if (!target.some((t: TargetConfiguration | string) => (typeof t === "string" && t === nsisTarget) || (t as TargetConfiguration).target === nsisTarget)) {
41+
if (
42+
!target
43+
.map((t: TargetConfiguration | string): string => {
44+
const result: string = typeof t === "string" ? t : t.target
45+
return result.toLowerCase().trim()
46+
})
47+
.some(t => t === nsisTarget)
48+
) {
4249
throw new Error("No nsis target found! Please specify an nsis target")
4350
}
4451
}

test/snapshots/windows/msiWrappedTest.js.snap

+29
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,34 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3+
exports[`msiWrapped allows capitalized nsis target 1`] = `
4+
Object {
5+
"win": Array [
6+
Object {
7+
"arch": "x64",
8+
"file": "Test MSI 1.1.0.msi",
9+
"safeArtifactName": "Test-MSI-1.1.0.msi",
10+
},
11+
Object {
12+
"arch": "x64",
13+
"file": "Test MSI Setup 1.1.0.exe",
14+
"safeArtifactName": "Test-MSI-Setup-1.1.0.exe",
15+
"updateInfo": Object {
16+
"sha512": "@sha512",
17+
"size": "@size",
18+
},
19+
},
20+
Object {
21+
"file": "Test MSI Setup 1.1.0.exe.blockmap",
22+
"safeArtifactName": "Test-MSI-Setup-1.1.0.exe.blockmap",
23+
"updateInfo": Object {
24+
"sha512": "@sha512",
25+
"size": "@size",
26+
},
27+
},
28+
],
29+
}
30+
`;
31+
332
exports[`msiWrapped impersonate no if not provided 1`] = `
433
Object {
534
"win": Array [

test/src/windows/msiWrappedTest.ts

+20
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,26 @@ test.ifAll.ifDevOrWinCi(
3333
)
3434
)
3535

36+
test.ifAll.ifDevOrWinCi(
37+
"msiWrapped allows capitalized nsis target",
38+
app(
39+
{
40+
targets: Platform.WINDOWS.createTarget(["msiWrapped", "NSIS"]),
41+
config: {
42+
appId: "build.electron.test.msi.oneClick.perMachine",
43+
extraMetadata: {
44+
// version: "1.0.0",
45+
},
46+
productName: "Test MSI",
47+
win: {
48+
target: ["msiWrapped", "NSIS"],
49+
},
50+
},
51+
},
52+
{}
53+
)
54+
)
55+
3656
test.ifAll.ifDevOrWinCi(
3757
"msiWrapped includes packaged exe",
3858
app({

0 commit comments

Comments
 (0)