Skip to content

fix(cli): resolve symlinks in direct-run guard - #46

Merged
koistya merged 1 commit into
mainfrom
dev
Mar 5, 2026
Merged

koistya merged 1 commit into
mainfrom
dev

Conversation

@koistya

@koistya koistya commented Mar 5, 2026

Copy link
Copy Markdown
Member

Summary

  • npx sideband silently exited because the direct-run guard compared process.argv[1] (npm .bin/ symlink) against fileURLToPath(import.meta.url) (real path) — they never matched, so main() never ran
  • Use realpathSync on both sides to normalize paths before comparing
  • Wrapped in try/catch so the guard stays non-throwing when argv[1] doesn't resolve
let isDirectRun = false;
try {
  isDirectRun =
    realpathSync(process.argv[1]!) ===
    realpathSync(fileURLToPath(import.meta.url));
} catch {
  // expected when argv[1] doesn't resolve to a real path
}

Test plan

  • New integration tests: direct invocation, symlink invocation, safe import
  • All 23 bin tests pass
  • ESLint + type check pass

`process.argv[1]` points to the npm `.bin/` symlink while
`import.meta.url` resolves to the real file path. The string comparison
never matched, so `main()` silently never ran.

Use `realpathSync` on both sides to normalize paths. Wrapped in
try/catch so the guard stays non-throwing when argv[1] doesn't exist
on disk (e.g. tests, embedded runtimes).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@koistya
koistya merged commit 6964d71 into main Mar 5, 2026
1 check passed
@koistya
koistya deleted the dev branch March 5, 2026 19:59
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