-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(cli): added --version and --help options #282
Conversation
added --version (-V) and --help (-h) options to the CLI for user interface.
Fixed a major bug with the version option in order to work from any directory
Uses dynamic import to import the node:path module when checking the version so it is not loaded when it is not needed.
Having just tested this revision on a windows OS, I can confirm that the help and version options work at the very least. It was not an extensive test, but I ran it with both options, ran it from a few different CWDs, and created a symlink and moved that around, and everything worked! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
removes not needed call to fileURLToPath, replacing with the URL object itself
Removed try-catch block in --version which provided a default response if the file system requests failed.
This should now be ready for review. The try-catch block has been removed, and I removed the extra call/import to |
Co-authored-by: fisker Cheung <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this!
🎉 This PR is included in version 2.2.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
added --version (-V) and --help (-h) options to the CLI for user interface.
--help
output:This help menu can be easily modified in cli.js. It includes the option from #281, but that could be easily removed if so desired.
--version
output:Or other such versions. The version is pulled from the project.json file in the cli script's directory.
This is found by reading process.env[1], using fs.realpathSync, to read symlinks when it's installed, and path.dirname to get the parent directory. From there it is simple to read the file and call JSON.parse.