Skip to content

[FEATURE] depadded script hook #962

@benallfree

Description

@benallfree

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Enhancementnew feature or improvement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions