unjs / nypm

🌈 Unified Package Manager for Node.js and Bun
MIT License
439 stars 13 forks source link

feat: ensurePackageInstalled utility #62

Closed dnldsht closed 10 months ago

dnldsht commented 1 year ago

Proposal for #53

I've done something similar as shown in the references by @antfu I've called addDependency. Should I make it more complex?

antfu commented 1 year ago

I think for ensurePackageInstalled we should minimalize the overhead to shortcircuit the CLI executing when the package is installed.

dnldsht commented 1 year ago

@antfu I'm willing to shortcircuit the CLI executing when the package is installed, but I'm not sure how to proceed, these are my ideas:

Should it also check the version of the package e.g. ensurePackageInstalled('nuxt@^3.0.0') must trigger addDependency if a lower version of nuxt is installed.

antfu commented 1 year ago

As you see in Vitest, we checked it using local-pkg. According to @pi0, I think here we plan to also port the functionality in local-pkg to be self-included.

pi0 commented 10 months ago

Thanks for the PR dear @dnldsht. A different implementation of ensureDependencyInstalled is merged via (rather big) https://github.com/unjs/nypm/pull/75 PR.

I would appreciate your review and feedback to improve that one ❤️