Misleading documentation
- Dominant language
- JavaScript
- Stars
- 45.7k
- Forks
- 1.3k
- PR merge metrics
- No merged PRs in 30d
Description
### Expected Behavior
The [documentation for within()](https://google.github.io/zx/api#within) does not use `cd()` due to it touching `process.cwd` and not reverting in some way, but having no mention of this side-effect as part of `within()`
### Actual Behavior
The [documentation for within()](https://google.github.io/zx/api#within) uses `cd()` which changes the `process.cwd` of the entire script and introduces parity between `process.cwd` and `` $`cd` ``
### Steps to Reproduce
1. Run this code for breaking example:
```js
echo("Script start");
echo(`- ${await $`pwd`}`); // => cwd
await within(async () => {
echo("First within");
cd("/");
echo(`- ${await $`pwd`}`); // => /
});
echo("Between within");
echo(`- ${await $`pwd`}`); // => cwd
await within(async () => {
echo("Second within");
echo(`- process CWD: ${process.cwd()}`); // => /
echo(`- ${await $`pwd`}`); // => cwd
});
echo("Script end");
echo(`- ${await $`pwd`}`); // => cwd
```
### Specifications
- zx version: 8.1.4
- Platform: macos
- Runtime: node
Contributor guide
Assessment
This issue has not been assessed yet.