npm supports the postinstall step (among many others), which may be exactly what you are looking for.
node.js heroku buildpack runs this command when you click on the hero to resolve build dependencies:
$ npm install
https://devcenter.heroku.com/articles/nodejs-support#build-behavior
If you look at the npm documentation, you can set up a series of scripts to run before or after someone runs npm install for your package. It is configured in the scripts property of package.json . The scripts property allows you to run your own scripts (including grunt ) when certain things happen in the package life cycle.
For example, to repeat the text and run the grunt command when someone (including Heroku) runs npm install , add this to your package.json :
{ ... "scripts": { "postinstall": "echo postinstall time; ./node_modules/grunt-cli/bin/grunt <your task name>" }, ... }
https://npmjs.org/doc/scripts.html
Important reservations:
- You may need to change the path to the grunt binary in the
postinstall script, check the error output if the grunt command fails. grunt and grunt-cli must be listed as dependency in your package.json , so Heroku will install it. Listing them in devDependencies not enough, since Heroku will not install them. Also note that Heroku will not install it as a global package, so you will have to use the relative path (as configured above) to run it on Heroku.
If that doesn't work (you probably have to play around with relative paths a bit), you might want to write your own buildpack for Heroku .
Update
Starting with version 0.4, the grunt package no longer contains the grunt binary, which is now part of the grunt-cli . The answer has been updated to reflect this.
smithclay Dec 10 '12 at 6:32 2012-12-10 06:32
source share