Skip to content

Commit a1935f5

Browse files
erickzhaogitbook-bot
authored andcommitted
GITBOOK-203: Clarify hook function stdout and stderr
1 parent de949a2 commit a1935f5

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

config/hooks.md

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ In Electron Forge, hooks are asynchronous callback functions that allow you to i
88

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

11-
Any writes to `stdout` and `stderr` from within a hook function will be printed in the console after the Forge build completes.
11+
{% hint style="warning" %}
12+
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.
13+
{% endhint %}
1214

1315
{% hint style="info" %}
1416
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
2123
### **`generateAssets`**
2224

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

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

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

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

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

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

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

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

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

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

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

175177
`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
183185
### `postMake`
184186

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

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

192-
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.
194+
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.
193195

194196
### `readPackageJson`
195197

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

0 commit comments

Comments
 (0)