Skip to content

Commit

Permalink
fix: adding log warning in case afterSign exists but no signing occ…
Browse files Browse the repository at this point in the history
…urred (#7388)
  • Loading branch information
mmaietta authored Jan 24, 2023
1 parent aeffe08 commit 1cb8f50
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .changeset/neat-peas-complain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"app-builder-lib": major
---

fix(BREAKING): Execute `afterSign` hook only when signing is completed, otherwise skip
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ jobs:
matrix:
testFiles:
- installerTest,appxTest,msiTest,portableTest,assistedInstallerTest,protonTest
- oneClickInstallerTest,winCodeSignTest,winPackagerTest,webInstallerTest
- BuildTest,oneClickInstallerTest,winCodeSignTest,winPackagerTest,webInstallerTest
steps:
- name: Checkout code repository
uses: actions/checkout@v3
Expand Down
10 changes: 6 additions & 4 deletions packages/app-builder-lib/src/platformPackager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -330,10 +330,12 @@ export abstract class PlatformPackager<DC extends PlatformSpecificBuildOptions>
electronPlatformName: platformName,
}
const didSign = await this.signApp(packContext, isAsar)
if (didSign) {
const afterSign = resolveFunction(this.config.afterSign, "afterSign")
if (afterSign != null) {
const afterSign = resolveFunction(this.config.afterSign, "afterSign")
if (afterSign != null) {
if (didSign) {
await Promise.resolve(afterSign(packContext))
} else {
log.warn(null, `skipping "afterSign" hook as no signing occurred, perhaps you intended "afterPack"?`)
}
}
}
Expand Down Expand Up @@ -428,7 +430,7 @@ export abstract class PlatformPackager<DC extends PlatformSpecificBuildOptions>

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

getIconPath(): Promise<string | null> {
Expand Down
2 changes: 1 addition & 1 deletion test/snapshots/BuildTest.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Object {
exports[`afterSign 1`] = `
Object {
"linux": Array [],
"mac": Array [],
"win": Array [],
}
`;

Expand Down
4 changes: 2 additions & 2 deletions test/src/BuildTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,12 +241,12 @@ test.ifLinuxOrDevMac("afterPack", () => {
)
})

test.ifLinuxOrDevMac("afterSign", () => {
test.ifWindows("afterSign", () => {
let called = 0
return assertPack(
"test-app-one",
{
targets: createTargets([Platform.LINUX, Platform.MAC], DIR_TARGET),
targets: createTargets([Platform.LINUX, Platform.WINDOWS], DIR_TARGET),
config: {
afterSign: () => {
called++
Expand Down

0 comments on commit 1cb8f50

Please sign in to comment.