fix(memfs): resolve relative streams from virtual cwd - #1271
Open
xianjianlf2 wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes relative-path stream operations in memfs by ensuring path resolution uses the virtual filesystem鈥檚 own process-like cwd() rather than the host Node.js process working directory, matching expected fs semantics and addressing #900.
Changes:
- Resolve
Superblockrelative paths against the volume鈥檚 configuredprocess.cwd()for core filesystem operations. - Set the default exported memfs instance (and
memfs()helper default) to use a virtual-rootcwd('/') so relative paths land inside the volume. - Add regression tests covering relative
createWriteStream()behavior for bothmemfs()instances and the default exportedfs.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/memfs/src/index.ts | Introduces a process-like wrapper to provide a virtual cwd and updates default volume initialization to avoid host-cwd resolution. |
| packages/memfs/src/tests/memfs.process.test.ts | Adds regression coverage for relative createWriteStream() paths on memfs() and the default exported fs. |
| packages/fs-node/src/tests/volume.process.test.ts | Verifies that relative writes resolve against a custom process.cwd() when provided to a Volume. |
| packages/fs-core/src/Superblock.ts | Routes filename-to-steps resolution through the volume鈥檚 process.cwd() so relative paths resolve within the virtual FS context. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #900.
Tests