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

program.opts() can be overridden by an option #584

Closed
rijnhard opened this issue Oct 21, 2016 · 1 comment
Closed

program.opts() can be overridden by an option #584

rijnhard opened this issue Oct 21, 2016 · 1 comment

Comments

@rijnhard
Copy link

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.

@shadowspawn
Copy link
Collaborator

I have referenced this issue as one of a number of related issues.

This issue has not had any activity in over six months. It isn't likely to get acted on due to this report.

Feel free to open a new issue if it comes up again, with new information and renewed interest.

Thank you for your contributions.

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

2 participants