Skip to content

Commit 588c5db

Browse files
authored
feat: add afterExtract hook for after electron distributable has been unpacked (#8194)
1 parent 2a9ccbf commit 588c5db

4 files changed

Lines changed: 37 additions & 0 deletions

File tree

.changeset/tough-clouds-think.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"app-builder-lib": minor
3+
---
4+
5+
feat: add `afterExtract` hook to build process with the same payload interface as `beforePack` and `afterPack`

packages/app-builder-lib/scheme.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6418,6 +6418,20 @@
64186418
],
64196419
"description": "The function (or path to file or module id) to be [run after all artifacts are build](#afterAllArtifactBuild)."
64206420
},
6421+
"afterExtract": {
6422+
"anyOf": [
6423+
{
6424+
"typeof": "function"
6425+
},
6426+
{
6427+
"type": [
6428+
"null",
6429+
"string"
6430+
]
6431+
}
6432+
],
6433+
"description": "The function (or path to file or module id) to be [run after the prebuilt Electron binary has been extracted to the output directory](#afterextract)"
6434+
},
64216435
"afterPack": {
64226436
"anyOf": [
64236437
{

packages/app-builder-lib/src/configuration.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,11 @@ export interface Configuration extends PlatformSpecificBuildOptions {
220220
*/
221221
readonly beforePack?: ((context: BeforePackContext) => Promise<any> | any) | string | null
222222

223+
/**
224+
* The function (or path to file or module id) to be [run after the prebuilt Electron binary has been extracted to the output directory](#afterextract)
225+
*/
226+
readonly afterExtract?: ((context: AfterExtractContext) => Promise<any> | any) | string | null
227+
223228
/**
224229
* The function (or path to file or module id) to be [run after pack](#afterpack) (but before pack into distributable format and sign).
225230
*/
@@ -297,6 +302,7 @@ interface PackContext {
297302
}
298303
export type AfterPackContext = PackContext
299304
export type BeforePackContext = PackContext
305+
export type AfterExtractContext = PackContext
300306

301307
export interface MetadataDirectories {
302308
/**

packages/app-builder-lib/src/platformPackager.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,18 @@ export abstract class PlatformPackager<DC extends PlatformSpecificBuildOptions>
245245
version: framework.version,
246246
})
247247

248+
const afterExtract = await resolveFunction(this.appInfo.type, this.config.afterExtract, "afterExtract")
249+
if (afterExtract != null) {
250+
await afterExtract({
251+
appOutDir,
252+
outDir,
253+
arch,
254+
targets,
255+
packager: this,
256+
electronPlatformName: platformName,
257+
})
258+
}
259+
248260
const excludePatterns: Array<Minimatch> = []
249261

250262
const computeParsedPatterns = (patterns: Array<FileMatcher> | null) => {

0 commit comments

Comments
 (0)