Skip to content

[node-core-library] Add createReadStream/createWriteStream to FileSystem#5757

Merged
iclanton merged 7 commits intomicrosoft:mainfrom
iclanton:new-filesystem-apis
Apr 8, 2026
Merged

[node-core-library] Add createReadStream/createWriteStream to FileSystem#5757
iclanton merged 7 commits intomicrosoft:mainfrom
iclanton:new-filesystem-apis

Conversation

@iclanton
Copy link
Copy Markdown
Member

@iclanton iclanton commented Apr 8, 2026

Summary

Add FileSystem.createReadStream() and FileSystem.createWriteStream() / createWriteStreamAsync() APIs to @rushstack/node-core-library, allowing consumers to use the FileSystem abstraction instead of importing fs directly for stream operations. Also extract a shared IFileSystemWriteFileOptionsBase interface and add an ensureFolderExists option to createWriteStream.

Details

  • Added FileSystem.createReadStream(filePath) — wraps fs.createReadStream() with Rush Stack's standard error handling via _wrapException.
  • Added FileSystem.createWriteStream(filePath, options?) and FileSystem.createWriteStreamAsync(filePath, options?) — wraps fs.createWriteStream() with support for the ensureFolderExists option to automatically create the parent directory.
  • Extracted IFileSystemWriteFileOptionsBase with the shared ensureFolderExists property, used by IFileSystemWriteBinaryFileOptions, IFileSystemMoveOptions, and the new IFileSystemCreateWriteStreamOptions.
  • Exported new type aliases FileSystemReadStream and FileSystemWriteStream so consumers don't need to import fs for stream types.
  • No backwards compatibility impact — all changes are additive.

How it was tested

Added unit tests covering:

  • createReadStream: reading file content via stream, error on nonexistent file
  • createWriteStream: writing data to a file, error when parent folder is missing, auto-creation of parent folder with ensureFolderExists: true
  • createWriteStreamAsync: writing data to a file, auto-creation of parent folder with ensureFolderExists: true

All 248 tests pass in the node-core-library package (7 new tests added).

Copilot AI and others added 6 commits April 8, 2026 12:36
…rary and update consumers to use FileSystem instead of fs directly

Agent-Logs-Url: https://github.com/microsoft/rushstack/sessions/5ad20d4d-c9a4-4855-bb13-8dd9e2c1350b

Co-authored-by: iclanton <5010588+iclanton@users.noreply.github.com>
…ore-library and update consumers to use FileSystem instead of fs directly

Wrap FileSystem stream methods in _wrapException for consistent error handling
…ore-library and update consumers to use FileSystem instead of fs directly
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@dmichon-msft dmichon-msft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few suggestions for readability and consistency.

Comment thread libraries/node-core-library/src/test/FileSystem.test.ts Outdated
Comment thread libraries/node-core-library/src/test/FileSystem.test.ts Outdated
…teration

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@iclanton iclanton enabled auto-merge (squash) April 8, 2026 20:27
@iclanton iclanton merged commit 48853d6 into microsoft:main Apr 8, 2026
6 checks passed
@github-project-automation github-project-automation Bot moved this from Needs triage to Closed in Bug Triage Apr 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Closed

Development

Successfully merging this pull request may close these issues.

3 participants