microsoft / microsoft/FluidFramework

Extract tryReadFile to a shared utility in build-cli

Open
#27,027 0 comments 0 reactions 1 assignee View on GitHub

@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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.