Skip to content

Commit 77895ce

Browse files
authored
docs: document launch in browsers better (#13002)
1 parent 132a7ce commit 77895ce

File tree

4 files changed

+86
-0
lines changed

4 files changed

+86
-0
lines changed

docs/browsers-api/browsers.launch.md

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ sidebar_label: launch
44

55
# launch() function
66

7+
Launches a browser process according to [LaunchOptions](./browsers.launchoptions.md).
8+
79
### Signature
810

911
```typescript

docs/browsers-api/browsers.launchoptions.md

+32
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ string\[\]
4747

4848
</td><td>
4949

50+
Additional arguments to pass to the executable when launching.
51+
5052
</td><td>
5153

5254
</td></tr>
@@ -64,8 +66,12 @@ boolean
6466

6567
</td><td>
6668

69+
Whether to spawn process in the [detached](https://nodejs.org/api/child_process.html#optionsdetached) mode.
70+
6771
</td><td>
6872

73+
`true` except on Windows.
74+
6975
</td></tr>
7076
<tr><td>
7177

@@ -81,8 +87,12 @@ boolean
8187

8288
</td><td>
8389

90+
If true, forwards the browser's process stdout and stderr to the Node's process stdout and stderr.
91+
8492
</td><td>
8593

94+
`false`.
95+
8696
</td></tr>
8797
<tr><td>
8898

@@ -98,6 +108,8 @@ Record&lt;string, string \| undefined&gt;
98108

99109
</td><td>
100110

111+
Environment variables to set for the browser process.
112+
101113
</td><td>
102114

103115
</td></tr>
@@ -113,6 +125,8 @@ string
113125

114126
</td><td>
115127

128+
Absolute path to the browser's executable.
129+
116130
</td><td>
117131

118132
</td></tr>
@@ -130,8 +144,12 @@ boolean
130144

131145
</td><td>
132146

147+
Handles SIGHUP in the Node process and tries to gracefully close the browser process.
148+
133149
</td><td>
134150

151+
`true`.
152+
135153
</td></tr>
136154
<tr><td>
137155

@@ -147,8 +165,12 @@ boolean
147165

148166
</td><td>
149167

168+
Handles SIGINT in the Node process and tries to kill the browser process.
169+
150170
</td><td>
151171

172+
`true`.
173+
152174
</td></tr>
153175
<tr><td>
154176

@@ -164,8 +186,12 @@ boolean
164186

165187
</td><td>
166188

189+
Handles SIGTERM in the Node process and tries to gracefully close the browser process.
190+
167191
</td><td>
168192

193+
`true`.
194+
169195
</td></tr>
170196
<tr><td>
171197

@@ -181,6 +207,8 @@ boolean
181207

182208
</td><td>
183209

210+
A callback to run after the browser process exits or before the process will be closed via the [Process.close()](./browsers.process.close.md) call (including when handling signals). The callback is only run once.
211+
184212
</td><td>
185213

186214
</td></tr>
@@ -198,7 +226,11 @@ boolean
198226

199227
</td><td>
200228

229+
Configures stdio streams to open two additional streams for automation over those streams instead of WebSocket.
230+
201231
</td><td>
202232

233+
`false`.
234+
203235
</td></tr>
204236
</tbody></table>

docs/browsers-api/index.md

+2
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,8 @@ Returns a version comparator for the given browser that can be used to sort brow
220220

221221
</td><td>
222222

223+
Launches a browser process according to [LaunchOptions](./browsers.launchoptions.md).
224+
223225
</td></tr>
224226
<tr><td>
225227

packages/browsers/src/launch.ts

+50
Original file line numberDiff line numberDiff line change
@@ -104,19 +104,69 @@ export function computeSystemExecutablePath(options: SystemOptions): string {
104104
* @public
105105
*/
106106
export interface LaunchOptions {
107+
/**
108+
* Absolute path to the browser's executable.
109+
*/
107110
executablePath: string;
111+
/**
112+
* Configures stdio streams to open two additional streams for automation over
113+
* those streams instead of WebSocket.
114+
*
115+
* @defaultValue `false`.
116+
*/
108117
pipe?: boolean;
118+
/**
119+
* If true, forwards the browser's process stdout and stderr to the Node's
120+
* process stdout and stderr.
121+
*
122+
* @defaultValue `false`.
123+
*/
109124
dumpio?: boolean;
125+
/**
126+
* Additional arguments to pass to the executable when launching.
127+
*/
110128
args?: string[];
129+
/**
130+
* Environment variables to set for the browser process.
131+
*/
111132
env?: Record<string, string | undefined>;
133+
/**
134+
* Handles SIGINT in the Node process and tries to kill the browser process.
135+
*
136+
* @defaultValue `true`.
137+
*/
112138
handleSIGINT?: boolean;
139+
/**
140+
* Handles SIGTERM in the Node process and tries to gracefully close the browser
141+
* process.
142+
*
143+
* @defaultValue `true`.
144+
*/
113145
handleSIGTERM?: boolean;
146+
/**
147+
* Handles SIGHUP in the Node process and tries to gracefully close the browser process.
148+
*
149+
* @defaultValue `true`.
150+
*/
114151
handleSIGHUP?: boolean;
152+
/**
153+
* Whether to spawn process in the {@link https://nodejs.org/api/child_process.html#optionsdetached | detached}
154+
* mode.
155+
*
156+
* @defaultValue `true` except on Windows.
157+
*/
115158
detached?: boolean;
159+
/**
160+
* A callback to run after the browser process exits or before the process
161+
* will be closed via the {@link Process.close} call (including when handling
162+
* signals). The callback is only run once.
163+
*/
116164
onExit?: () => Promise<void>;
117165
}
118166

119167
/**
168+
* Launches a browser process according to {@link LaunchOptions}.
169+
*
120170
* @public
121171
*/
122172
export function launch(opts: LaunchOptions): Process {

0 commit comments

Comments
 (0)