Skip to content

Commit 14edbca

Browse files
authored
Revert factory function reexport (#2014)
1 parent 384f17b commit 14edbca

File tree

2 files changed

+14
-20
lines changed

2 files changed

+14
-20
lines changed

index.js

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ const program = new Command();
1414
exports = module.exports = program; // default export (deprecated)
1515
exports.program = program; // more explicit access to global command
1616

17+
// createArgument, createCommand, and createOption are implicitly available as they are methods on program.
18+
1719
/**
1820
* Expose classes
1921
*/
@@ -26,14 +28,3 @@ exports.Help = Help;
2628
exports.CommanderError = CommanderError;
2729
exports.InvalidArgumentError = InvalidArgumentError;
2830
exports.InvalidOptionArgumentError = InvalidArgumentError; // Deprecated
29-
30-
/**
31-
* Expose object factory functions.
32-
*
33-
* These are present implicitly, but need to be explicit
34-
* to work with TypeScript whole module import (import * as foo) when esModuleInterop: true.
35-
*/
36-
37-
exports.createCommand = program.createCommand;
38-
exports.createArgument = program.createArgument;
39-
exports.createOption = program.createOption;

tests/ts-imports.test.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,18 @@ describe('import * as commander', () => {
102102
checkClass(new commander.InvalidOptionArgumentError('failed'), 'InvalidArgumentError');
103103
});
104104

105-
test('createCommand', () => {
106-
checkClass(commander.createCommand('foo'), 'Command');
107-
});
105+
// Factory functions are not found if esModuleInterop is true, so comment out tests for now.
106+
// Can uncomment these again when we drop the default export of global program and add the factory functions explicitly.
108107

109-
test('createOption', () => {
110-
checkClass(commander.createOption('-e, --example', 'description'), 'Option');
111-
});
108+
// test('createCommand', () => {
109+
// checkClass(commander.createCommand('foo'), 'Command');
110+
// });
112111

113-
test('createArgument', () => {
114-
checkClass(commander.createArgument('<foo>', 'description'), 'Argument');
115-
});
112+
// test('createOption', () => {
113+
// checkClass(commander.createOption('-e, --example', 'description'), 'Option');
114+
// });
115+
116+
// test('createArgument', () => {
117+
// checkClass(commander.createArgument('<foo>', 'description'), 'Argument');
118+
// });
116119
});

0 commit comments

Comments
 (0)