Skip to content

fix: run the CLI when reached through the bin symlink - #11

Merged
blaipr merged 1 commit into
mainfrom
fix/cli-symlink-guard
Sep 2, 2026
Merged

blaipr merged 1 commit into
mainfrom
fix/cli-symlink-guard

Conversation

@blaipr

@blaipr blaipr commented Sep 2, 2026

Copy link
Copy Markdown
Member

What this changes

cdmon and cdmon-mcp now run when invoked through the symlinks npm link / npm install -g create. The main-module guard resolves both import.meta.url and process.argv[1] through the filesystem before comparing them, via a new isInvokedDirectly() exported for testing. docs/installation.md mentions npm link.

Why

Node resolves the entry point's symlinks before loading it, so import.meta.url names the real dist/cli.js, while process.argv[1] is the path as typed — .../node_modules/.bin/cdmon. The two never matched from an installed command, so the module loaded, ran nothing, and exited 0. cdmon --help printed nothing; a deploy step in CI would have reported success without doing anything. Reproduced with a symlink to dist/cli.js before the change, and confirmed fixed after.

Checklist

  • npm test passes
  • npm run typecheck passes
  • Documentation in docs/ updated if behaviour changed
  • CHANGELOG.md updated if the change is user-observable
  • No credentials, hostnames or database names in the diff

@blaipr
blaipr merged commit 7a3e69d into main Sep 2, 2026
2 checks passed
@blaipr
blaipr deleted the fix/cli-symlink-guard branch September 2, 2026 22:07
@blaipr blaipr mentioned this pull request Sep 2, 2026
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant