Commit 6f42f64 1 parent f45110c commit 6f42f64 Copy full SHA for 6f42f64
File tree 4 files changed +36
-1
lines changed
4 files changed +36
-1
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " app-builder-lib " : minor
3
+ ---
4
+
5
+ feat: add ` beforePack ` hook to build process with the same payload interface as that of ` afterPack `
Original file line number Diff line number Diff line change 6025
6025
],
6026
6026
"description" : " The function (or path to file or module id) to be [run after all artifacts are build](#afterAllArtifactBuild)."
6027
6027
},
6028
+ "beforePack" : {
6029
+ "anyOf" : [
6030
+ {
6031
+ "typeof" : " function"
6032
+ },
6033
+ {
6034
+ "type" : [
6035
+ " null" ,
6036
+ " string"
6037
+ ]
6038
+ }
6039
+ ],
6040
+ "description" : " The function (or path to file or module id) to be [run before pack](#beforepack)"
6041
+ },
6028
6042
"afterPack" : {
6029
6043
"anyOf" : [
6030
6044
{
Original file line number Diff line number Diff line change @@ -195,6 +195,8 @@ export interface Configuration extends PlatformSpecificBuildOptions {
195
195
*/
196
196
readonly framework ?: string | null
197
197
198
+ readonly beforePack ?: ( ( context : BeforePackContext ) => Promise < any > | any ) | string | null
199
+
198
200
/**
199
201
* The function (or path to file or module id) to be [run after pack](#afterpack) (but before pack into distributable format and sign).
200
202
*/
@@ -262,14 +264,16 @@ export interface Configuration extends PlatformSpecificBuildOptions {
262
264
readonly removePackageKeywords ?: boolean
263
265
}
264
266
265
- export interface AfterPackContext {
267
+ interface PackContext {
266
268
readonly outDir : string
267
269
readonly appOutDir : string
268
270
readonly packager : PlatformPackager < any >
269
271
readonly electronPlatformName : string
270
272
readonly arch : Arch
271
273
readonly targets : Array < Target >
272
274
}
275
+ export type AfterPackContext = PackContext
276
+ export type BeforePackContext = PackContext
273
277
274
278
export interface MetadataDirectories {
275
279
/**
Original file line number Diff line number Diff line change @@ -201,6 +201,18 @@ export abstract class PlatformPackager<DC extends PlatformSpecificBuildOptions>
201
201
return
202
202
}
203
203
204
+ const beforePack = resolveFunction ( this . config . beforePack , "beforePack" )
205
+ if ( beforePack != null ) {
206
+ await beforePack ( {
207
+ appOutDir,
208
+ outDir,
209
+ arch,
210
+ targets,
211
+ packager : this ,
212
+ electronPlatformName : platformName ,
213
+ } )
214
+ }
215
+
204
216
await this . info . installAppDependencies ( this . platform , arch )
205
217
206
218
if ( this . info . cancellationToken . cancelled ) {
You can’t perform that action at this time.
0 commit comments