refactor: replace read-pkg with native fs.readFile + JSON.parse#4742
Conversation
read-pkg is used in one place (@packages/utils/pkg-check.js, an internal dev tool). Replacing it with a 3-line helper using node:fs/promises.readFile + JSON.parse lets us drop the dep without losing functionality. Closes #4673 as superseded. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Review Summary by QodoRemove read-pkg dependency with native fs implementation
WalkthroughsDescription• Replace read-pkg dependency with native Node.js fs/promises API • Add inline readPkg() helper using readFile() and JSON.parse() • Remove read-pkg from package.json dependencies • Simplify package.json call from object to string parameter Diagramflowchart LR
A["read-pkg dependency"] -->|"Replace with"| B["readFile + JSON.parse"]
B -->|"Implement as"| C["readPkg helper function"]
C -->|"Update call in"| D["main function"]
D -->|"Remove from"| E["package.json dependencies"]
File Changes1. @packages/utils/pkg-check.js
|
Code Review by Qodo
1. Opaque JSON parse errors
|
There was a problem hiding this comment.
Pull request overview
Refactors the internal @commitlint/utils dev tool (pkg-check) to stop using read-pkg by reading package.json via native fs/promises.readFile and JSON.parse, allowing removal of the direct read-pkg dependency (superseding #4673).
Changes:
- Replace
read-pkgusage in@packages/utils/pkg-check.jswith a small localreadPkg(cwd)helper usingreadFile + JSON.parse. - Remove
read-pkgfrom@packages/utilsdependencies. - Update
yarn.lockto drop the removed direct dependency subtree.
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
@packages/utils/pkg-check.js |
Replaces read-pkg call sites with a local JSON reader helper. |
@packages/utils/package.json |
Removes the direct read-pkg dependency from this workspace package. |
yarn.lock |
Removes lockfile entries associated with the deleted direct dependency. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
read-pkg is used in one place (@packages/utils/pkg-check.js, an internal dev tool). Replacing it with a 3-line helper using node:fs/promises.readFile + JSON.parse lets us drop the dep without losing functionality. Closes #4673 as superseded.