Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>npm has a support for a <code>postinstall</code> step (among many others) that might be just what you're looking for.</p> <p>The node.js heroku buildpack runs this command when you push to heroku to resolve build dependencies:</p> <pre><code>$ npm install --production </code></pre> <p><a href="https://devcenter.heroku.com/articles/nodejs-support#build-behavior" rel="noreferrer">https://devcenter.heroku.com/articles/nodejs-support#build-behavior</a></p> <p>If you take a look at the npm documentation, you can setup a series of scripts to run either before or after anyone runs <code>npm install</code> for your package. It's configured in the <code>scripts</code> property of <code>package.json</code>. The <code>scripts</code> property allows to run custom scripts (including <code>grunt</code>) when certain things happen in a package's lifecycle.</p> <p>For example, to echo some text and run the <code>grunt</code> command whenever anyone (including Heroku) runs <code>npm install</code>, add this to your <code>package.json</code>:</p> <pre><code>{ ... "scripts": { "postinstall": "echo postinstall time; ./node_modules/grunt-cli/bin/grunt &lt;your task name&gt;" }, ... } </code></pre> <p><a href="https://npmjs.org/doc/scripts.html" rel="noreferrer">https://npmjs.org/doc/scripts.html</a></p> <p>Important caveats:</p> <ul> <li>You might have to change the path to the grunt binary in the <code>postinstall</code> script, check the error output if the <code>grunt</code> command doesn't execute.</li> <li><code>grunt</code> and <code>grunt-cli</code> must be listed as a <code>dependency</code> in your <code>package.json</code> so it gets installed by Heroku. Listing them under <code>devDependencies</code> is not sufficient since Heroku won't install those. Also, note that Heroku won't install it as a global package so to execute it on Heroku you're going to have to use a relative path (as it is configured above).</li> </ul> <p>If this doesn't work (you'll probably need to fiddle with the relative paths a bit), then you might want to consider writing <a href="https://devcenter.heroku.com/articles/buildpack-api" rel="noreferrer">your own custom buildpack for Heroku</a>.</p> <h2>Update</h2> <p>As of 0.4, the <code>grunt</code> package no longer contains the <code>grunt</code> binary, which is now part of the <code>grunt-cli</code> package. The answer has been updated to reflect this.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload