Skip to content

Commit 918969d

Browse files
docs(api): document cwd option for spawning processes (#76)
1 parent 25d1fe0 commit 918969d

File tree

2 files changed

+26
-12
lines changed

2 files changed

+26
-12
lines changed

docs/api.md

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,18 @@ The main export of this library. An instance of `WebContainer` represents a runt
3030

3131
Gives access to the underlying file system.
3232

33+
<br />
34+
35+
#### <code>path: string</code>
36+
37+
The default value of the `PATH` environment variable for processes started through [`spawn`](#▸-spawn).
38+
39+
<br />
40+
41+
#### <code>workdir: string</code>
42+
43+
The full path to the working directory (see [FileSystemAPI](#filesystemapi)).
44+
3345
### `WebContainer` Methods
3446

3547
### `boot`
@@ -245,16 +257,6 @@ All entities derived from this instance (e.g. processes, the file system, etc.)
245257

246258
## `auth`
247259

248-
::: warning
249-
This namespace is currently only available under the `beta` tag. If you want to use it you will need to install this version specifically:
250-
251-
```bash
252-
npm install @webcontainer/api@beta
253-
```
254-
255-
We don't guarantee backwards compatibility between beta versions.
256-
:::
257-
258260
The authentication API is exported under the `auth` namespace. It allows you to authenticate users visiting your website via StackBlitz. In order for users to be authenticated via this method, they must:
259261

260262
* Be logged in on StackBlitz.
@@ -265,8 +267,6 @@ Once logged in, you'll be able to install private packages that those users have
265267

266268
### `auth` Functions
267269

268-
<br />
269-
270270
### `init`
271271

272272
Intialize the authentication for use in WebContainer. This method should be called as soon as possible as part of the loading phase of your page. For example at the top of a module that gets loaded as soon as the page loads. This is important for multiple reasons:
@@ -851,6 +851,7 @@ Options that control spawning a process.
851851

852852
```ts
853853
export interface SpawnOptions {
854+
cwd?: string;
854855
env?: Record<string, string | number | boolean>;
855856
output?: boolean;
856857
terminal?: { cols: number; rows: number };
@@ -861,6 +862,14 @@ export interface SpawnOptions {
861862

862863
<br />
863864

865+
#### `cwd?: string`
866+
867+
Current working directory for the process, relative to [`workdir`](#workdir-string) this instance (which you can change when [booting `WebContainer`](#▸-boot)).
868+
869+
By default, the working directory of the spawned process is [`workdir`](#workdir-string).
870+
871+
<br />
872+
864873
#### `env?: Record<string, string | number | boolean>`
865874

866875
Environment variables to set for the process.

docs/changelog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ head:
1010

1111
# Changelog
1212

13+
## 1.2.0
14+
15+
* Add support for [`authentication`](api#auth).
16+
* add [`cwd`](api#▸-cwd-string) option to [`SpawnOptions`](api#spawnoptions).
17+
1318
## 1.1.8
1419

1520
* Add [`fs.watch`](api#▸-watch).

0 commit comments

Comments
 (0)