Expected Behavior
The documentation for 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() uses cd() which changes the process.cwd of the entire script and introduces parity between process.cwd and $`cd`
Steps to Reproduce
- Run this code for breaking example:
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
Expected Behavior
The documentation for within() does not use
cd()due to it touchingprocess.cwdand not reverting in some way, but having no mention of this side-effect as part ofwithin()Actual Behavior
The documentation for within() uses
cd()which changes theprocess.cwdof the entire script and introduces parity betweenprocess.cwdand$`cd`Steps to Reproduce
Specifications