nypm
nypm copied to clipboard
fix: Correct yarn detection
Hi! 👋 Thanks for the project, it has been of great help for my own project: https://github.com/LekoArts/secco
I've found a small bug in this codepath:
const packageManager =
packageManagers.find(
(pm) => pm.name === name && pm.majorVersion === majorVersion,
) || packageManagers.find((pm) => pm.name === name);
The comparison of pm.majorVersion === majorVersion
will currently be 3.0.0 === 3
, so it'll fall back to the first name found. So if you e.g. run the detection in a yarn berry project you won't get back the files
array.
In 3b0f0aa14f2d8efa03c1b5f713f31dee29c58fc3 I added the assertion of files
to the tests, which then were failing. The commit after that fixes it.
I'll leave some inline comments that we could consider for future PRs but I wanted to discuss first.