Fix handling of cli arg that is symlink #659
Merged
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.
Summary
I've had trouble running
checksync
for quite a while. I had to resort to running it by passing the entrypoint file to node manuallynode path/to/checksync.js
.The error I'd see is this:
Issues
I haven't raised an issue for this. I can, if you'd like. :)
Details
I finally traced the error to how symlinks are resolved for unrecognized args.
The process sees a
__filename
of/Users/jeremy/.volta/tools/image/packages/checksync/bin/checksync
. On my system,fs.readlinkSync(__filename)
returns../lib/node_modules/.bin/checksync
. Whenpath.resolve()
resolves that path, it ends up at a path that doesn't exist on my system because it joinsprocess.cwd()
with the relative path passed topath.resolve()
.I think the fix is just to use
fs.realpathSync()
which appears to resolve to the right path on my system.Screenshots
If applicable, add screenshots to help illustrate your changes
Review notes
Add additional context for reviewers here. Consider what, if anything, needs particular attention paid to it.
If this is a draft, perhaps clarify what work remains and what, if anything, is ready for review.