Skip to content

docs: explain syncProcessCwd async contexts#1476

Open
KirtiRamchandani wants to merge 1 commit into
google:mainfrom
KirtiRamchandani:docs/sync-process-cwd-contexts
Open

docs: explain syncProcessCwd async contexts#1476
KirtiRamchandani wants to merge 1 commit into
google:mainfrom
KirtiRamchandani:docs/sync-process-cwd-contexts

Conversation

@KirtiRamchandani
Copy link
Copy Markdown

Problem

Issue #876 notes that the current docs mention cd() and syncProcessCwd(), but do not explain the async-context mismatch that can happen when cd() changes the global process directory while within() restores only zx's internal $ context.

Root cause

The syncProcessCwd() section only states what the hook does. It does not show how process.cwd() can drift from $ in separate callbacks, or when users should prefer $.cwd instead.

Solution

Add examples showing the mismatch without the hook and the restored behavior with syncProcessCwd() enabled, plus guidance to use $.cwd for zx-only directory changes.

Tests run

  • npm exec --yes prettier -- --check docs/api.md
  • git diff --check

Fixes #876

@antonmedv
Copy link
Copy Markdown
Collaborator

@antongolub looks right and explanatory to me. ptal

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Misleading documentation

2 participants