title: Is there a way to fork a npm library in package.json and run its build process on install?
body: <p>I have a npm dependency (e.g. <code>ngx-infinite-scroll</code>) that I'm currently trying to fork (for bug fixes) and include my forked version as a dependency in my application. Below an example of the include in my <code>package.json</code>:</p>
  
  <pre><code>  "dependencies": {
      "ngx-infinite-scroll": "github:jcroll/ngx-infinite-scroll#bugfixes",
    },
  </code></pre>
  
  <p>In the above I've forked the repo at github and created a new branch called <code>bugfixes</code>.</p>
  
  <p>My problem is that the maintainer runs a build process that creates an artifact in a <code>./dist</code> directory and then publishes this flat directory to npm using <code>$ npm run publish ./dist</code>. However, when I install my new forked repo via <code>$ npm i ngx-infinite-scroll</code> the entire repo is downloaded and <em>not</em> the <code>dist</code> dir.</p>
  
  <p>Now I know this should be expected. One thing I was hoping to do was at least get the <code>dist</code> dir to be created on install by adding to the scripts of the library's <code>package.json</code>:</p>
  
  <pre><code>  "scripts": {
      ...
      "prepare": "npm run build"
    },
  </code></pre>
  
  <p>However I still do not see the <code>dist</code> directory on install. Even then I would still have to alter the package.json to point the <code>module</code> key to this new nested directory entry point.</p>
  
  <p>What I would like <em>instead</em> is when I install this library from github is to have it publish its flattened <code>dist</code> directory as the top level directory of the library just like how the original library installs by the maintainer building the library and running <code>$ npm rub publish ./dist</code>. Is there any way to do this?</p>
  
  <p><strong>Edit:</strong> I am also aware via <a href="https://stackoverflow.com/questions/17509669/how-to-install-an-npm-package-from-github-directly">this answer</a> that I could build the dist and commit the code to this new branch but I'd like a more elegant way, hence the question.</p>