microsoft / microsoft/FluidFramework
Extract tryReadFile to a shared utility in build-cli
@tylerbutler is already working on this.
Since Apr 14, 2026.
- Dominant language
- TypeScript
- Stars
- 4.9k
- Forks
- 586
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 146
Description
Summary
build-tools/packages/build-cli/src/commands/ai.ts defines a tryReadFile helper (lines 344-360) that reads a file and returns undefined on ENOENT, rethrowing on all other errors. The same ENOENT-swallow pattern already exists in build-tools/packages/build-cli/src/library/pnpmCatalog.ts (lines 27-33).
Proposal
Extract tryReadFile into a shared location — src/library/text.ts already houses file I/O helpers (readLines, writeFileWithLineFeeds) and is a natural home. Then update both ai.ts and pnpmCatalog.ts to import from the shared location.
Context
Identified during code reuse review of the flub ai PR. Deferred because the refactor touches code outside the PR's scope.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.