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

package.json autodetection fails if not used as a direct dependency #7

Closed
jwheare opened this issue Jul 21, 2016 · 1 comment
Closed

Comments

@jwheare
Copy link

jwheare commented Jul 21, 2016

As noted in: sindresorhus/electron-store#1 (comment)

Perhaps this can just be mentioned in the README as a caveat, but if no projectName or cwd is provided, conf tries to detect the package.json of the parent package.

However, this uses the module.parent mechanism, which returns the nearest direct dependent, rather than the top level package.

conf/index.js

Line 13 in c5a736b

const parentDir = path.dirname(module.parent.filename);

This can cause issues if a module is using conf via an intermediary.

@sindresorhus
Copy link
Owner

The problem is that we can't really know which module in the tree is the correct one. It might be the direct parent, it might be top level, or somewhere in between. I think auto-detecting the direct one and falling back to an option is a good compromise, but happy to consider other solutions. And yes, should be documented better regardless.

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