Alexander Myshov
Alexander Myshov

Reputation: 3101

Is it possible to run some script on each npm install event?

I want to install pre-push hooks for git on each npm install event. Is it possible? Maybe is there some alternative solution? By the way I don't want to install stuff like gulp, I want to use only npm.

Upvotes: 3

Views: 127

Answers (1)

Andrei CACIO
Andrei CACIO

Reputation: 2119

If I understood correctly, you can do something like this:

in your package.json file you can add install hooks like so:

{
  "scripts": {
    "install": "scripts/install.js",
    "postinstall": "scripts/postinstall.js",
    "uninstall": "scripts/uninstall.js"
  }
}

the postinstall.js will be executed after you install a package. Having this in mind, you can create a shell script which can do the git push's for you.

Is this something you are looking for?

Upvotes: 2

Related Questions