Skip to content

Instantly share code, notes, and snippets.

@leon
Created November 8, 2013 15:09
Show Gist options
  • Save leon/7372337 to your computer and use it in GitHub Desktop.
Save leon/7372337 to your computer and use it in GitHub Desktop.
Grunt.js install bower components and force the latest version, great if you're running the rc version of angular.js
/*
grunt task that calls bower install with --force-latest
simply call 'bower' from a registerTask.
grunt.registerTask('install', [
'clean',
'bower',
'bower_postinst' // good grunt plugin if you want to build something from sources, in my case I'm building angular-bootstraps 3.0.0 branch
]);
*/
// place this above your grunt.initConfig({...})
grunt.registerTask('bower', 'Install js packages listed in bower.json', function () {
var done = this.async();
var bower = require('bower');
var cli = require('bower/lib/util/cli');
var cmd = bower.commands.install.line(['--force-latest']);
var renderer = cli.getRenderer('--force-latest', cmd.json, bower.config);
cmd
.on('log', function(log){
renderer.log(log);
})
.on('end', function(data) {
renderer.end(data);
done();
})
.on('error', function(err) {
renderer.error(err);
done();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment