Hooks
Hooks¶
Node.js 8
All examples assumed that you use latest Node.js 8.11.x or higher.
beforePack¶
The function (or path to file or module id) to be run before pack.
(context: BeforePackContext): Promise<any> | any
As function
beforePack: async (context) => {
// your code
}
Because in a configuration file you cannot use JavaScript, can be specified as a path to file or module id. Function must be exported as default export.
"build": {
"beforePack": "./myBeforePackHook.js"
}
File myBeforePackHook.js
in the project root directory:
myBeforePackHook.js
exports.default = async function(context) {
// your custom code
}
afterPack¶
The function (or path to file or module id) to be run after pack (but before pack into distributable format and sign).
(context: AfterPackContext): Promise<any> | any
As function
afterPack: async (context) => {
// your code
}
Because in a configuration file you cannot use JavaScript, can be specified as a path to file or module id. Function must be exported as default export.
"build": {
"afterPack": "./myAfterPackHook.js"
}
File myAfterPackHook.js
in the project root directory:
myAfterPackHook.js
exports.default = async function(context) {
// your custom code
}
afterSign¶
The function (or path to file or module id) to be run after pack and sign (but before pack into distributable format).
(context: AfterPackContext): Promise<any> | any
Configuration in the same way as afterPack
(see above).
afterAllArtifactBuild¶
The function (or path to file or module id) to be run after all artifacts are built.
(buildResult: BuildResult): Promise<Array<string>> | Array<string>
Configuration in the same way as afterPack
(see above).
myAfterAllArtifactBuild.js
exports.default = function () {
// you can return additional files to publish
return ["/path/to/additional/result/file"]
}
onNodeModuleFile¶
The function (or path to file or module id) to be run on each node module file.
(file: string) => void
Configuration in the same way as afterPack
(see above).
AfterPackContext¶
interface AfterPackContext {
outDir: string
appOutDir: string
packager: PlatformPackager<any>
electronPlatformName: string
arch: Arch
targets: Array<Target>
}
BuildResult¶
interface BuildResult {
outDir: string
artifactPaths: Array<string>
platformToTargets: Map<Platform, Map<string, Target>>
configuration: Configuration
}