Adds bower to node dependencies, uses bower to get the typeahead dependency, gets bower dependencies on npm install

This commit is contained in:
Shannon
2014-05-05 15:55:48 +10:00
parent 956a92f5b4
commit 27e6b8c80c
5 changed files with 62 additions and 7 deletions

View File

@@ -14,7 +14,7 @@ module.exports = function (grunt) {
grunt.registerTask('watch-test', ['jshint:dev', 'karma:unit']);
//triggered from grunt dev or grunt
grunt.registerTask('build', ['clean','concat','recess:min','recess:installer','copy']);
grunt.registerTask('build', ['clean','concat','recess:min','recess:installer','bower','copy']);
//utillity tasks
grunt.registerTask('docs', ['ngdocs']);
@@ -26,6 +26,28 @@ module.exports = function (grunt) {
grunt.log.subhead(Date());
});
// Custom task to run the bower dependency installer
// tried, a few other things but this seems to work the best.
// https://coderwall.com/p/xnkdqw
grunt.registerTask('bower', 'Get js packages listed in bower.json',
function () {
var bower = require('bower');
var done = this.async();
bower.commands.install(undefined, { offline: true }, { interactive: false, offline: true })
.on('log', function (data) {
grunt.log.write(data.message + "\n");
})
.on('error', function (data) {
grunt.log.write(data.message + "\n");
done(false);
})
.on('end', function (data) {
done();
});
}
);
// Project configuration.
grunt.initConfig({
@@ -58,7 +80,8 @@ module.exports = function (grunt) {
},
distdir: 'build/belle',
vsdir: '../Umbraco.Web.Ui/umbraco',
bowerfiles: 'bower_components',
vsdir: '../Umbraco.Web.UI/umbraco',
pkg: grunt.file.readJSON('package.json'),
banner:
'/*! <%= pkg.title || pkg.name %> - v<%= buildVersion %> - <%= grunt.template.today("yyyy-mm-dd") %>\n' +
@@ -86,6 +109,14 @@ module.exports = function (grunt) {
clean: ['<%= distdir %>/*'],
copy: {
// Copies over the files downloaded by bower
bower: {
files: [
{ dest: '<%= distdir %>/lib/typeahead/typeahead.bundle.min.js', src: '<%= bowerfiles %>/typeahead.js/dist/typeahead.bundle.min.js' }
]
},
assets: {
files: [{ dest: '<%= distdir %>/assets', src : '**', expand: true, cwd: 'src/assets/' }]
},