fix(cli): resolve bundled config and package.json relative to module#25
Merged
Merged
Conversation
CLI read './typograf.json' and './package.json' relative to the current working directory, so it crashed with ENOENT from any directory other than the package root. Resolve both paths from import.meta.url instead.
2858353 to
30bfcb0
Compare
Collaborator
|
Thank you! |
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.
The CLI reads
./typograf.json(bundled default config) and./package.json(for--version) relative to the current working directory. As a result the command crashes withENOENT: no such file or directory, open './typograf.json'when run from any directory other than the package root — which is every real invocation of a globally installed CLI.This was introduced when the CLI moved to ESM (6.2.0); the previous CJS version resolved these via
require(.../typograf.json), which is module-relative.Fix: resolve both paths from
import.meta.urlinstead of CWD.bin/utils.mjs— bundledtypograf.jsonbin/cli.mjs—package.jsonfor--versionVerified the CLI now works from an arbitrary CWD (stdin processing and
--version);npm test(eslint) passes.🤖 Generated with Claude Code