From a1935f5f4002b31a4d718bd9e57b59d1f9f22f20 Mon Sep 17 00:00:00 2001 From: Erick Zhao Date: Thu, 13 Feb 2025 04:29:03 +0000 Subject: [PATCH] GITBOOK-203: Clarify hook function stdout and stderr --- config/hooks.md | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/config/hooks.md b/config/hooks.md index 09411de..af311c4 100644 --- a/config/hooks.md +++ b/config/hooks.md @@ -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. @@ -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`** @@ -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`** `preStart()` is invoked before Forge's **`start`** command launches the app in dev mode. @@ -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`** `postStart()` called after Forge's **`start`** command launches the app in dev mode. @@ -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`** @@ -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 @@ -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 @@ -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 @@ -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 @@ -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`** `preMake()` is called before the **`make`** step runs. @@ -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`** - Full package.json object * **Returns: `Promise | void>`**