How to install git hooks on "npm install"?
<p>I'd like to install a <code>pre-commit</code> git hook (that lints the code) when someone installs <code>my-package</code>.</p>

<p>I tried to add a <code>postinstall</code> script:</p>

<pre><code>"scripts": {
  "postinstall": "./scripts/install-git-hooks"
}
</code></pre>

<p>This works great. When someone runs <code>npm install</code>, they get the <code>pre-commit</code> hook installed.</p>

<p>However, if <code>another-package</code> depends on <code>my-package</code>, running <code>npm install</code> for <code>another-package</code> runs the <code>postinstall</code> script as well, which is undesired.</p>

<p>What's the cleanest way to avoid this undesired affect?</p>