nypm icon indicating copy to clipboard operation
nypm copied to clipboard

fix: Correct yarn detection

Open LekoArts opened this issue 7 months ago • 0 comments

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.

LekoArts avatar Jul 05 '24 07:07 LekoArts