fix: resolve symlinks in entry guard so npx invocation runs main()#6
Conversation
|
Caution Review failedPull request was closed or merged during review WalkthroughThe module now imports 🚥 Pre-merge checks | ✅ 1✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/index.ts`:
- Around line 146-148: The code calls realpathSync(process.argv[1]) unguarded
which throws if process.argv[1] is undefined or the path is missing; change the
logic in src/index.ts around realSelf/realArgv to first check/process.argv[1]
and handle errors before comparing: compute realSelf as before, then set
realArgv to null by default and, if process.argv[1] is a non-empty string,
attempt to realpathSync it inside a try/catch (or use fs.existsSync) and set
realArgv only on success; finally only perform the equality check if realArgv is
non-null. Reference symbols: realSelf, realArgv, realpathSync, fileURLToPath,
import.meta.url, process.argv[1].
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: ef407c9b-268c-43e3-97ba-47433c07c809
📒 Files selected for processing (1)
src/index.ts
Summary
When invoked via
npx,process.argv[1]is the symlink path (node_modules/.bin/coval-wizard) whileimport.meta.urlresolves to the real file path. The strict equality check fails somain()never runs.Fix: use
realpathSync+fileURLToPathto resolve both sides before comparing.Fixes
Changes