+
Skip to content

Misleading documentation #876

Open
Open
@gear4s

Description

@gear4s

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

  1. 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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载