-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Check that dependencies are install before running scripts #8585
Comments
Since automatically install dependencies could pose security risks, how about just check if the lockfile is up-to-date? If the lockfile is out-of-date (either because it doesn't match What do you think? |
That's good enough for me. |
The issue with this is that |
I plan to only run this validation on the very first Furthermore, this feature will be disabled by default. |
It isn't enough to check if the lockfile is up-to-date. You also need to check if node_modules is up to date, which can be done by comparing During install I would store somewhere the modification times of package.json files and lockfiles and then during run I guess you could consider everything up to date if the modification times didn't change. Hopefully this would be fast enough as you'd only need to read attributes instead of reading and parsing big files. Although in a big workspace you'd need to read attributes of many |
With all the above optimizations that I suggested one expensive operation remains: searching for all the workspace projects in the filesystem. To verify that the lockfile is up to date we check if the set of workspace projects remains the same. |
I didn't expect that this feature would be so complex. But the PR is done. |
Contribution
Describe the user story
It's easy to begin development with the wrong dependencies installed. Here's some examples:
Describe the solution you'd like
Normally you'd have to remember to run
pnpm i
in these scenarios. I'd like pnpm to "remember" for me.Before I run a script in the
"scripts"
field of thepackage.json
(orpnpm test
, etc.), I'd like pnpm to check that the correct dependencies are installed then either:pnpm i
pnpm i
in the background).Describe the drawbacks of your solution
pnpm i
can pose security risks (becausepostinstall
scripts can run arbitrary code), so doing this should be opt-in on the developer-level in my opinion.Describe alternatives you've considered
Keep the status quo.
The text was updated successfully, but these errors were encountered: