Skip to content

Commit 1cb8f50

Browse files
authored
fix: adding log warning in case afterSign exists but no signing occurred (#7388)
1 parent aeffe08 commit 1cb8f50

File tree

5 files changed

+15
-8
lines changed

5 files changed

+15
-8
lines changed

Diff for: .changeset/neat-peas-complain.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"app-builder-lib": major
3+
---
4+
5+
fix(BREAKING): Execute `afterSign` hook only when signing is completed, otherwise skip

Diff for: .github/workflows/test.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ jobs:
100100
matrix:
101101
testFiles:
102102
- installerTest,appxTest,msiTest,portableTest,assistedInstallerTest,protonTest
103-
- oneClickInstallerTest,winCodeSignTest,winPackagerTest,webInstallerTest
103+
- BuildTest,oneClickInstallerTest,winCodeSignTest,winPackagerTest,webInstallerTest
104104
steps:
105105
- name: Checkout code repository
106106
uses: actions/checkout@v3

Diff for: packages/app-builder-lib/src/platformPackager.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -330,10 +330,12 @@ export abstract class PlatformPackager<DC extends PlatformSpecificBuildOptions>
330330
electronPlatformName: platformName,
331331
}
332332
const didSign = await this.signApp(packContext, isAsar)
333-
if (didSign) {
334-
const afterSign = resolveFunction(this.config.afterSign, "afterSign")
335-
if (afterSign != null) {
333+
const afterSign = resolveFunction(this.config.afterSign, "afterSign")
334+
if (afterSign != null) {
335+
if (didSign) {
336336
await Promise.resolve(afterSign(packContext))
337+
} else {
338+
log.warn(null, `skipping "afterSign" hook as no signing occurred, perhaps you intended "afterPack"?`)
337339
}
338340
}
339341
}
@@ -428,7 +430,7 @@ export abstract class PlatformPackager<DC extends PlatformSpecificBuildOptions>
428430

429431
// eslint-disable-next-line @typescript-eslint/no-unused-vars
430432
protected signApp(packContext: AfterPackContext, isAsar: boolean): Promise<any> {
431-
return Promise.resolve(true)
433+
return Promise.resolve(false)
432434
}
433435

434436
getIconPath(): Promise<string | null> {

Diff for: test/snapshots/BuildTest.js.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Object {
1010
exports[`afterSign 1`] = `
1111
Object {
1212
"linux": Array [],
13-
"mac": Array [],
13+
"win": Array [],
1414
}
1515
`;
1616

Diff for: test/src/BuildTest.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -241,12 +241,12 @@ test.ifLinuxOrDevMac("afterPack", () => {
241241
)
242242
})
243243

244-
test.ifLinuxOrDevMac("afterSign", () => {
244+
test.ifWindows("afterSign", () => {
245245
let called = 0
246246
return assertPack(
247247
"test-app-one",
248248
{
249-
targets: createTargets([Platform.LINUX, Platform.MAC], DIR_TARGET),
249+
targets: createTargets([Platform.LINUX, Platform.WINDOWS], DIR_TARGET),
250250
config: {
251251
afterSign: () => {
252252
called++

0 commit comments

Comments
 (0)