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

fix: avoid legacy accessors #2013

Merged
merged 8 commits into from Oct 7, 2021
Merged
18 changes: 13 additions & 5 deletions index.cjs
Expand Up @@ -28,15 +28,23 @@ function singletonify(inst) {
...Object.getOwnPropertyNames(inst.constructor.prototype),
].forEach(key => {
if (key === 'argv') {
Argv.__defineGetter__(key, inst.__lookupGetter__(key));
Object.defineProperty(Argv, key, Object.getOwnPropertyDescriptor(inst, key));
} else if (typeof inst[key] === 'function') {
Argv[key] = inst[key].bind(inst);
} else {
Argv.__defineGetter__('$0', () => {
return inst.$0;
Object.defineProperty(Argv, '$0', {
configurable: true,
enumerable: true,
get() {
return inst.$0;
}
});
Argv.__defineGetter__('parsed', () => {
return inst.parsed;
Object.defineProperty(Argv, '$0', {
bmeck marked this conversation as resolved.
Show resolved Hide resolved
configurable: true,
enumerable: true,
get() {
return inst.parsed;
}
});
}
});
Expand Down