Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save possibilities/e4fbeaa29d4d60708b7c7519094cd69f to your computer and use it in GitHub Desktop.
Save possibilities/e4fbeaa29d4d60708b7c7519094cd69f to your computer and use it in GitHub Desktop.

Commander.js Version Check Report

Date: 2025-07-06
Purpose: Verify that all Commander.js CLIs properly report their package.json version

Summary

Checked 10 projects in ~/code that use Commander.js. All projects successfully built, but one project (fs-to-xml) has a runtime dependency issue.

Overall Results

  • 9 of 10 projects have matching CLI and package.json versions
  • ⚠️ 1 of 10 projects has a missing dependency preventing version check
  • ⚠️ 7 of 9 working projects incorrectly output "Error:" with their version
  • 2 of 9 working projects (context-composer-cli, tmux-composer-cli) have clean version output

Detailed Results

Project Package Version CLI Version Status Notes
fs-to-xml 0.1.0 ❌ Error ⚠️ Runtime Error Missing 'bash-parser' dependency
theme-installer-cli 0.1.1 0.1.1 ✅ Match ⚠️ Outputs "Error: 0.1.1"
meta-composer-cli 0.1.0 0.1.0 ✅ Match ⚠️ Outputs "Error: 0.1.0"
context-composer-cli 0.1.0 0.1.0 ✅ Match ✅ Clean output
commanderjs-template 0.1.0 0.1.0 ✅ Match ⚠️ Outputs "Error: 0.1.0"
claude-code-generic-hooks 0.1.4 0.1.4 ✅ Match ⚠️ Outputs "Error: 0.1.4"
claude-code-inject 0.1.7 0.1.7 ✅ Match ⚠️ Outputs "Error: 0.1.7"
claude-code-chat-stream 0.1.3 0.1.3 ✅ Match ⚠️ Outputs "Error: 0.1.3"
tmux-composer-cli 0.1.1 0.1.1 ✅ Match ✅ Clean output
comment-destroyer 0.1.0 0.1.0 ✅ Match ⚠️ Outputs "Error: 0.1.0"

Issues Found

1. fs-to-xml - Missing Dependency

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'bash-parser' imported from /home/mike/code/fs-to-xml/dist/cli.js
  • The project builds successfully but fails at runtime
  • Missing 'bash-parser' dependency prevents version check
  • Recommendation: Add 'bash-parser' to package.json dependencies

2. Incorrect "Error:" Output in Version Display

Most projects (7 out of 9 working ones) incorrectly display "Error: " when running --version. This happens because:

  • These projects use program.exitOverride() in their Commander.js setup
  • When --version is called, Commander throws an error with code commander.version
  • The error handling code doesn't check for this specific error code
  • The version number gets printed as an error message

Affected Projects:

  • theme-installer-cli
  • meta-composer-cli
  • commanderjs-template
  • claude-code-generic-hooks
  • claude-code-inject
  • claude-code-chat-stream
  • comment-destroyer

Clean Output Projects:

  • context-composer-cli ✅
  • tmux-composer-cli ✅

Fix:

Add a check for commander.version in the error handling:

if (
  error.code === 'commander.help' ||
  error.code === 'commander.helpDisplayed' ||
  error.code === 'commander.version'
) {
  process.exit(0)
}

Common Characteristics

All projects share these traits:

  • Use Commander.js ^12.0.0
  • Built with tsup
  • TypeScript-based
  • ES modules ("type": "module")
  • Require Node.js 18+
  • All have executable at ./dist/cli.js

Conclusion

While all functional projects correctly report their version numbers, most have a cosmetic issue where the version is incorrectly prefixed with "Error:". This is due to incomplete error handling when using exitOverride() with Commander.js.

Action Items:

  1. Fix fs-to-xml by adding the missing 'bash-parser' dependency
  2. Update error handling in 7 projects to properly handle the commander.version error code
  3. Use context-composer-cli or tmux-composer-cli as reference implementations for clean version output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment