tj / commander.js

node.js command-line interfaces made easy

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Drop default import of global Command (for CommonJS)

shadowspawn opened this issue · comments

The default import of a global Command object (aka program) has been out of favour since Commander v5, deprecated since v7, removed from the TypeScript in v8, and never implemented for the explicit esm support (#1440).

In general with the deprecated features and behaviours, I am willing to leave them alone until they cause problems rather than aggressively remove them, to minimise breaking changes when people upgrade from old versions of Commander.

The global Command object was involved in recent problems with TypeScript (#2013 #2014), so I am suggesting removing it while I am still annoyed! 😠

To be clear, this will still work:

const { program } = require('commander');
program.parse();

And this:

const commander = require('commander');
const program = new commander.Command();
program.parse();

But this won't work anymore:

const commander = require('commander');
commander.parse();

Released in Commander v12.0.0.