sindresorhus / read-package-up

Read the closest package.json file
MIT License
258 stars 18 forks source link

Proposal: change api #13

Closed fisker closed 5 years ago

fisker commented 5 years ago

You renamed .package in https://github.com/sindresorhus/read-pkg-up/commit/8140c731da0c4ddfedd549d55660acf0ee53ee1d .

But why not readPkgUp and readPkgUp.sync for the json, add readPkgUp.resolve and readPkgUp.resolve.sync to get the path, just like require

sindresorhus commented 5 years ago

What if you want both at the same time? Then it would have to search twice, which could also cause race conditions.

fisker commented 5 years ago

I would do readPkgUp.resolve get the path then require or readjson

Just like I usually do with require, require.resolve then require

sindresorhus commented 5 years ago

Then I would have to document how to use it properly and people will still not read it and do it wrong. With destructuring, the current API is fine, IMHO.

fisker commented 5 years ago

Sure, just suggestion.

sindresorhus commented 5 years ago

Another reason not to do it is that I just did two major versions for silly stuff, so I don't really want to cause more churn.