There is no way to do this using npm scripts. So, if you donβt feel that you are implementing one of them, you will have to customize your process. Start by identifying all the problems you are trying to solve with a hook-dependent installation.
You give an example of preventing the installation of a dependent or dependent version. This is not a problem: this is the solution you identified for the problem. Find out what the actual problem is, and then reevaluate your solution to make sure that this is indeed the most appropriate measure.
Perhaps (perhaps) you are afraid of vulnerable code that does this before production. This is a definition of a problem that you can work with. What are the possible solutions? You have already defined a blacklist. But not only this is not supported by your tools, even if it was due to the fact that you kept a blacklist. Considering how fast the world of Node is moving, this is enough to keep several people in full. And this does not even allow you to deploy it for your developers.
The good news is that this is not the only solution: you can establish procedural guarantees against the integration of vulnerable code. If you use a distributed VCS, such as Git, the upload requests are right there: disable clicking on the transfer of authority to the host or development branches, force developers to work in the function branches and send pull requests, and then look at these pull requests and display any new ones dependencies for vulnerabilities when they appear. If you use something like SVN, you can use function branches with code reviews with a similar effect. Your developers get additional views on their code looking for vulnerabilities, optimization, edge cases, etc .; You donβt spend time screening dependencies that no one ever tries to integrate. And no one should worry about getting the latest copy of the blacklist. For this particular scenario, everyone wins with a technological solution over a technical solution.
If you have other reasons to run scripts when installing dependencies, try returning to the root of the problem the same way. As dependency and interaction management with the Node module works, you will probably find that it is preferable to develop better process habits.
source share