Closed DaniGuardiola closed 5 years ago
This module accepts an object with options, not a string. See the docs.
I see, well my bad and thanks for pointing it out. However, this is not coherent with the other modules such as readPkg
or pkgUp
, I suggest changing it (or adding support for a string argument additionally to the the options object) for consistency.
In fact, I'll change this to make the issue a proposal instead of a bug.
readPkg
has a string argument as it's reads better readPkg(packagePath)
, while readPkgUp
finds the package path for you, so it's different. The inconsistent one here is pkgUp
, which should accept and object with options instead of string.
I think this module should at least validate the input argument though. That would have caught your issue.
This is the current behavior:
Current behavior
Code
Output
Proposal
In my view,
readPkgUp
should behave just likepkgUp + readPkg
for consistency, and both executions above should return the correctpackage.json
object.This could be implemented as a non-breaking change, because the options object can still work fine but the module could detect whether the input argument is an object or a string and work with both formats.