Type alias HookFunction

HookFunction: ((buildPath, electronVersion, platform, arch, callback) => void)

A function that is called on the completion of a packaging stage.

By default, the functions are called in parallel (via Promise.all). If you need the functions called serially, there is a utility function provided. Please note that callback-style functions are not supported by serialHooks.

Type declaration

    • (buildPath, electronVersion, platform, arch, callback): void
    • Parameters

      • buildPath: string

        For afterExtract, the path to the temporary folder where the prebuilt Electron binary has been extracted to. For afterCopy and afterPrune, the path to the folder where the Electron app has been copied to. For afterComplete, the final directory of the packaged application.

      • electronVersion: string

        the version of Electron that is being bundled with the application.

      • platform: TargetPlatform

        The target platform you are packaging for.

      • arch: TargetArch

        The target architecture you are packaging for.

      • callback: HookFunctionErrorCallback

        Must be called once you have completed your actions.

      Returns void

Example

const packager = require('@electron/packager')
const { serialHooks } = require('@electron/packager/src/hooks')

packager({
// ...
afterCopy: [serialHooks([
(buildPath, electronVersion, platform, arch) => {
return new Promise((resolve, reject) => {
setTimeout(() => {
console.log('first function')
resolve()
}, 1000)
})
},
(buildPath, electronVersion, platform, arch) => {
console.log('second function')
}
])],
// ...
})

For real-world examples of HookFunctions, see the list of related plugins.