Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

commander-version

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

commander-version

A wrapper for Commander that automatically sets the version based on your package.json

  • 1.1.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

commander-version

npm typescript GitHub stars Twitter Follow

A wrapper for Commander that automatically sets the version based on your package.json.

Installation

yarn add commander-version
npm install commander-version

API

Default

To set the version, import program the same as you would for Commander, just pass __dirname:

import program from "commander-version";

program(__dirname)
  .name("my-program")
  .description("...")
  // ...
  .parse();

This creates a new Command rather than using the global Command, which can cause issues.

Flags and Description

You can also add flags or descriptions the same as with program.version():

Note: the default flags are set to "-v --version" to be inline with other programs, such as Node.js.

import program from "commander-version";

// To set flags back to the Commander default of "-V --version", for example:

program(__dirname, "-V --version", "custom version description")
  .name("my-program")
  .description("...")
  // ...
  .parse();

Types

For creating types, the Commander namespace can also be imported:

import { commander } from "commander-version";

type MyType = commander.Command;

Commander

For convenience, Commander and createCommand can also be used without setting the version:

import { commander, createCommand } from "commander-version";

new commander.Command("my-command")
  .description("...")
  // ...

const myCommand = createCommand("my-command")
  .description("...")
  // ...

Dependenciesdependencies

  • @bconnorwhite/module: Read your module's package.json without importing it
  • commander: the complete solution for node.js command-line programs

Dev DependenciesDavid


License license

MIT

Keywords

FAQs

Package last updated on 14 Sep 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc