title: Running npm `postinstall` script after the original `npm install` finishes? (Maybe by using a Node trick?)
body: <p>I'm trying to create an npm module that has a <code>postinstall</code> script that will modify the user's <code>package.json</code> and re-install packages. I'm almost there, but the problem I'm having is that the npm CLI runs my <code>postinstall</code> script too early.</p>
  
  <p>Is there a way, maybe by using Node or system level trick, to wait for the whole <code>npm install</code> process to exit before my script runs? Like when npm calls my <code>postinstall</code> script, at that time I can register another script to run after <code>npm install</code> finishes?</p>
  
  <p>What do I mean by "too early"? For example, after <code>yarn install</code>, the <code>yarn.lock</code> file will not accurately reflect the <code>package.json</code> if my script interferes with <code>yarn install</code>. However, if my script waits for <code>yarn install</code> to completely finish and then runs another <code>yarn install</code>, the <code>yarn.lock</code> file will be accurate and further <code>yarn install</code> commands will output "Already up-to-date".</p>