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

Using hasOwnProperty breaks for config objects with null prototype #1372

Closed
cspotcode opened this issue Jul 2, 2019 · 2 comments · Fixed by #1376
Closed

Using hasOwnProperty breaks for config objects with null prototype #1372

cspotcode opened this issue Jul 2, 2019 · 2 comments · Fixed by #1376
Labels

Comments

@cspotcode
Copy link
Contributor

I'm loading a config object from a third-party library, then passing it to yargs. This library happens to return an object with a null prototype. yargs breaks because it's trying to call config.hasOwnProperty.

https://github.com/yargs/yargs/blob/master/lib/apply-extends.js#L22

@bcoe
Copy link
Member

bcoe commented Jul 9, 2019

@cspotcode any chance you could provide a minimal reproduction of the issue?

@bcoe bcoe added the bug label Jul 9, 2019
@cspotcode
Copy link
Contributor Author

https://runkit.com/5d12741cd8940e00146b7254/5d24bb163b4b940013e6d846

In my case the config object is coming from another library which is doing the right thing: it's returning an object with a null prototype, which is generally easier to work with as a dictionary. That's all correct and good. yargs just needs a tiny patch to fix how it's using hasOwnProperty.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment