-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Description
What / Why
I would like the ability to run scripts before and after dependencies are added. The install hook runs after the package is installed as a dependency, but we have no hooks for when a dependency is added/removed from a package.
I'm proposing a depadded hook to run after a package dependency is installed using npm i <package>.
When
When npm i <package> is finished executing
Where
As a final step, it will look for a depadded script in the project package.json and run it if present.
How
"scripts": {
"depadded": "echo 'A dependency was added.'"
}Current Behavior
There is no way to hook into a dependency added event.
Expected Behavior
- n/a
Who
- n/a
References
Inspired while trying to find a workaround for npm install breaking npm link. I created a package to help track and restore links, but there is no way to automatically run it after npm install <package> executes.
I know this particular issue will be fixed in npm 7, but perhaps there is some general utility to this feature anyway. I am happy to work on it and submit a PR.