fix: npx/global bin does nothing (0.1.1 hotfix) - #6
Conversation
The entry-point guard compared import.meta.url to argv[1] directly, but npm runs the bin through a symlink (node_modules/.bin/gitgotchi), so the paths never matched and `npx gitgotchi` exited 0 doing nothing. Resolve argv[1]'s real path before comparing. Extracted isDirectRun() and covered the symlink case with a test. Bumps 0.1.0 → 0.1.1. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Claude finished @dvd90's task in 2m 1s —— View job Review: fix/bin-symlink-entry
Verdict: looks good, approving the approach. This is a correct, well-scoped hotfix. Root cause & fix TDD / CLAUDE.md conventions
Product principles
Minor, non-blocking note
Verification note: I was not able to run |
Critical: published 0.1.0 is dead on its headline command
npx gitgotchi(andnpm i -g gitgotchi→gitgotchi) exits 0 and prints nothing.Cause: the entry-point guard compared
import.meta.urltoprocess.argv[1]directly. npm runs a package'sbinthrough a symlink (node_modules/.bin/gitgotchi→dist/cli.js), soargv[1]is the symlink path whileimport.meta.urlis the real file — they never match, the run block is skipped, and the process does nothing.Verified locally:
node dist/cli.jsprinted the pet;node <symlink-to-cli.js>printed nothing.Fix: resolve
argv[1]to its real path before comparing. ExtractedisDirectRun(metaUrl, argv1)and added a test that builds a real file + a symlink to it and asserts both resolve as the entry point (the regression this guards).src/cli.ts:realpathSync(argv[1])in the entry checktest/cli.test.ts: symlink entry-point test0.1.0→0.1.1131 tests green, typecheck + lint clean. After merge this needs a
npm publishof 0.1.1 (0.1.0 should be deprecated).🤖 Generated with Claude Code