Skip to content
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

Can we get a --version, -V? Willing to patch. #58

Open
coolaj86 opened this issue Oct 1, 2024 · 0 comments
Open

Can we get a --version, -V? Willing to patch. #58

coolaj86 opened this issue Oct 1, 2024 · 0 comments

Comments

@coolaj86
Copy link

coolaj86 commented Oct 1, 2024

I've got script that relies on this and I'd like to have it print out the version at the beginning as this also gives a good opportunity for the install prompt.

# causes install prompt if not already installed, then shows version
npx -p [email protected] -- ts-to-jsdoc --version

Here's roughly how I would add it:

let pkg = require('./package.json');

function showVersion() {
  console.info(`${pkg.name} v${pkg.version}`);
}

let versionFlags = [`--version`, `-V`, `version`];
for (let flag of versionFlags) {
  let wantsVersion = process.argv.includes(flag)
  if (wantsVersion) {
    showVersion();
    process.exit(0);
    return;
  }
}
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

No branches or pull requests

1 participant