Skip to content

Commit

Permalink
GITBOOK-203: Clarify hook function stdout and stderr
Browse files Browse the repository at this point in the history
  • Loading branch information
erickzhao authored and gitbook-bot committed Feb 13, 2025
1 parent de949a2 commit a1935f5
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions config/hooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ In Electron Forge, hooks are asynchronous callback functions that allow you to i

Each hook function comes with the Forge configuration object as a first parameter.

Any writes to `stdout` and `stderr` from within a hook function will be printed in the console after the Forge build completes.
{% hint style="warning" %}
Any writes to `stdout` and `stderr` from within a hook function will be printed in the console after the Forge build completes, and will only be visible with the `DEBUG` or `CI` environment variables set to some truthy value.
{% endhint %}

{% hint style="info" %}
To read more about the different stages in Forge's build process, please refer to the [build-lifecycle.md](../core-concepts/build-lifecycle.md "mention") documentation.
Expand All @@ -21,7 +23,7 @@ In Electron Forge, most hooks are **simple hooks**, which perform side effects d
### **`generateAssets`**

* **Arguments:**
* **`config:`**[**`ResolvedForgeConfig`**](https://js.electronforge.io/interfaces/\_electron\_forge\_shared\_types.ResolvedForgeConfig.html) - Forge configuration object
* **`config:`**[**`ResolvedForgeConfig`**](https://js.electronforge.io/interfaces/_electron_forge_shared_types.ResolvedForgeConfig.html) - Forge configuration object
* **`platform: string`** - Operating system platform
* **`arch: string`** - CPU architecture
* **Returns: `Promise<void>`**
Expand All @@ -35,7 +37,7 @@ For instance, you could use this hook to generate a license file containing the
### `preStart`

* **Arguments:**
* **`config:`**[**`ResolvedForgeConfig`**](https://js.electronforge.io/interfaces/\_electron\_forge\_shared\_types.ResolvedForgeConfig.html) - Forge configuration object
* **`config:`**[**`ResolvedForgeConfig`**](https://js.electronforge.io/interfaces/_electron_forge_shared_types.ResolvedForgeConfig.html) - Forge configuration object
* **Returns: `Promise<void>`**

`preStart()` is invoked before Forge's **`start`** command launches the app in dev mode.
Expand All @@ -57,8 +59,8 @@ module.exports = {
### `postStart`

* **Arguments:**
* **`config:`**[**`ResolvedForgeConfig`**](https://js.electronforge.io/interfaces/\_electron\_forge\_shared\_types.ResolvedForgeConfig.html) - Forge configuration object
* **`appProcess:`**[**`ChildProcess`**](https://nodejs.org/api/child\_process.html#class-childprocess) **-** Node.js child process instance
* **`config:`**[**`ResolvedForgeConfig`**](https://js.electronforge.io/interfaces/_electron_forge_shared_types.ResolvedForgeConfig.html) - Forge configuration object
* **`appProcess:`**[**`ChildProcess`**](https://nodejs.org/api/child_process.html#class-childprocess) **-** Node.js child process instance
* **Returns: `Promise<void>`**

`postStart()` called after Forge's **`start`** command launches the app in dev mode.
Expand All @@ -80,7 +82,7 @@ module.exports = {
### `prePackage`

* **Arguments:**
* **`config:`**[**`ResolvedForgeConfig`**](https://js.electronforge.io/interfaces/\_electron\_forge\_shared\_types.ResolvedForgeConfig.html) - Forge configuration object
* **`config:`**[**`ResolvedForgeConfig`**](https://js.electronforge.io/interfaces/_electron_forge_shared_types.ResolvedForgeConfig.html) - Forge configuration object
* **`platform: string`** - Operating system platform
* **`arch: string`** - CPU architecture
* **Returns: `Promise<void>`**
Expand All @@ -90,7 +92,7 @@ module.exports = {
### `packageAfterCopy`

* **Arguments:**
* **`config:`**[**`ResolvedForgeConfig`**](https://js.electronforge.io/interfaces/\_electron\_forge\_shared\_types.ResolvedForgeConfig.html) - Forge configuration object
* **`config:`**[**`ResolvedForgeConfig`**](https://js.electronforge.io/interfaces/_electron_forge_shared_types.ResolvedForgeConfig.html) - Forge configuration object
* **`buildPath: string`**- the app's temporary folder path
* **`electronVersion: string`**- the app's Electron version
* **`platform: string`** - Operating system platform
Expand All @@ -106,7 +108,7 @@ The `afterCopy` hook runs after this copy step.
### `packageAfterPrune`

* **Arguments:**
* **`config:`**[**`ResolvedForgeConfig`**](https://js.electronforge.io/interfaces/\_electron\_forge\_shared\_types.ResolvedForgeConfig.html)- Forge configuration object
* **`config:`**[**`ResolvedForgeConfig`**](https://js.electronforge.io/interfaces/_electron_forge_shared_types.ResolvedForgeConfig.html)- Forge configuration object
* **`buildPath: string`**- the app's temporary folder path
* **`electronVersion: string`**- the app's Electron version
* **`platform: string`** - Operating system platform
Expand All @@ -126,7 +128,7 @@ The `afterPrune` hook runs after this prune step.
### `packageAfterExtract`

* **Arguments:**
* **`config:`**[**`ResolvedForgeConfig`**](https://js.electronforge.io/interfaces/\_electron\_forge\_shared\_types.ResolvedForgeConfig.html)- Forge configuration object
* **`config:`**[**`ResolvedForgeConfig`**](https://js.electronforge.io/interfaces/_electron_forge_shared_types.ResolvedForgeConfig.html)- Forge configuration object
* **`buildPath: string`**- the Electron binary's temporary folder path
* **`electronVersion: string`**- the app's Electron version
* **`platform: string`** - Operating system platform
Expand All @@ -142,7 +144,7 @@ The `afterExtract` hook runs after this extract step.
### `postPackage`

* **Arguments:**
* **`config:`**[**`ResolvedForgeConfig`**](https://js.electronforge.io/interfaces/\_electron\_forge\_shared\_types.ResolvedForgeConfig.html)- Forge configuration object
* **`config:`**[**`ResolvedForgeConfig`**](https://js.electronforge.io/interfaces/_electron_forge_shared_types.ResolvedForgeConfig.html)- Forge configuration object
* **`packageResult: Object`**
* **`platform: string`** - Operating system platform
* **`arch: string`** - CPU architecture
Expand All @@ -169,7 +171,7 @@ module.exports = {
### `preMake`

* **Arguments:**
* **`config:`**[**`ResolvedForgeConfig`**](https://js.electronforge.io/interfaces/\_electron\_forge\_shared\_types.ResolvedForgeConfig.html)- Forge configuration object
* **`config:`**[**`ResolvedForgeConfig`**](https://js.electronforge.io/interfaces/_electron_forge_shared_types.ResolvedForgeConfig.html)- Forge configuration object
* **Returns: `Promise<void>`**

`preMake()` is called before the **`make`** step runs.
Expand All @@ -183,18 +185,18 @@ The returned value will replace the original parameter's value for subsequent st
### `postMake`

* **Arguments:**
* **`config:`**[**`ResolvedForgeConfig`**](https://js.electronforge.io/interfaces/\_electron\_forge\_shared\_types.ResolvedForgeConfig.html)- Forge configuration object
* **`makeResults:`**[**`MakeResult`**](https://js.electronforge.io/interfaces/\_electron\_forge\_shared\_types.ForgeMakeResult.html)**`[]`**
* **Returns: `Promise<`**[**`MakeResult`**](https://js.electronforge.io/interfaces/\_electron\_forge\_shared\_types.ForgeMakeResult.html)**`[] | void>`**
* **`config:`**[**`ResolvedForgeConfig`**](https://js.electronforge.io/interfaces/_electron_forge_shared_types.ResolvedForgeConfig.html)- Forge configuration object
* **`makeResults:`**[**`MakeResult`**](https://js.electronforge.io/interfaces/_electron_forge_shared_types.ForgeMakeResult.html)**`[]`**
* **Returns: `Promise<`**[**`MakeResult`**](https://js.electronforge.io/interfaces/_electron_forge_shared_types.ForgeMakeResult.html)**`[] | void>`**

`postMake()`is called after Forge's **`make`** step has successfully completed.

It is passed an array of [`MakeResult`](https://js.electronforge.io/interfaces/\_electron\_forge\_shared\_types.ForgeMakeResult.html) objects that are output from the `make` step. If you wish to mutate the array of Make results, you can return a new array of [`MakeResult`](https://js.electronforge.io/interfaces/\_electron\_forge\_shared\_types.ForgeMakeResult.html) objects that Electron Forge can use for future steps.
It is passed an array of [`MakeResult`](https://js.electronforge.io/interfaces/_electron_forge_shared_types.ForgeMakeResult.html) objects that are output from the `make` step. If you wish to mutate the array of Make results, you can return a new array of [`MakeResult`](https://js.electronforge.io/interfaces/_electron_forge_shared_types.ForgeMakeResult.html) objects that Electron Forge can use for future steps.

### `readPackageJson`

* **Arguments:**
* **`config:`**[**`ResolvedForgeConfig`**](https://js.electronforge.io/interfaces/\_electron\_forge\_shared\_types.ResolvedForgeConfig.html)- Forge configuration object
* **`config:`**[**`ResolvedForgeConfig`**](https://js.electronforge.io/interfaces/_electron_forge_shared_types.ResolvedForgeConfig.html)- Forge configuration object
* **`packageJson: Record<string, unknown>`** - Full package.json object
* **Returns: `Promise<Record<string, unknown> | void>`**

Expand Down

0 comments on commit a1935f5

Please sign in to comment.