I want to build a tool that is run on every npm install call, just like the npm audit
.
For now, I have used the postinstall
script, simply because it works.
This is what the output looks like of a npm install
command:
users-MacBook-Pro:hello_world user$ npm install
>hello_world@1.0.0 postinstall /Users/user/my-nice-tool/hello_world
>node hello_world.js
Hello World!
up to date in 0.494s
found 0 vulnerabilities
My tool shows "Hello World!" just above the built-in vulnerability check (npm audit
), which is perfectly fine and wanted.
At the moment, my package.json
file looks like this:
{ bla bla,
"scripts": {
"postinstall": "node hello_world.js"
},
bla bla
}
But then I encountered this question and its answers, which stated that there are types of scripts that are not always run, depending on the mode they are run in/the arguments passed to npm install
...
So my question is: does anyone know what kind of script I should use, just to make sure that my tool works as I want it to every time?