-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Description
import program from 'commander';
program.getOptions = program.opts;
console.log('program.opts before', program.opts); // prints body of opts() function
program.option('--opts <path>', 'specify opts path', 'test/mocha.opts');
program.parse(process.argv);
console.log('program.opts after', program.opts); // prints test/mocha.opts
console.log('program.opts()', program.opts()); // errors, is not a function
console.log('program.opts().opts', program.getOptions().opts); // this is the workaround that works.Shouldnt the function be protected from being overridden?
it's easy enough to use program.opts().opts to get any properties that would override default functions.
But in cases (like in the mocha code) where they are using the overridden property program.opts it will introduce errors.
Thus it is a breaking change. but none the less the workaround introduce more problems with reuse then anything else.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels