kurtinatlanta
kurtinatlanta

Reputation: 108

Bootstrap 3.0.1 bower.json breaks grunt-bower-task

Twitter Bootstrap 3.0.1 changes the "main" attribute of their bower.json to look like this:

"main": ["./dist/js/bootstrap.js", "./dist/css/bootstrap.css", "./dist/fonts/*"],

They added the "./dist/fonts/*" item in 3.0.1 - it was not there in 3.0.0.

Now, when I run bower:install from my Gruntfile, I get this error:

Running "bower:install" (bower) task
bower cached https://github.com/twbs/bootstrap.git#3.0.1
bower validate 3.0.1 against https://github.com/twbs/bootstrap.git#>= 3.0.0
bower cached https://github.com/components/jquery.git#2.0.3
bower validate 2.0.3 against https://github.com/components/jquery.git#>= 2.0.0
bower cached https://github.com/components/jquery.git#2.0.3
bower validate 2.0.3 against https://github.com/components/jquery.git#>= 1.9.0
bower install jquery#2.0.3
bower install bootstrap#3.0.1
>> Installed bower packages
grunt-bower copying bower_components/bootstrap/dist/js/bootstrap.js -> public/bootstrap/bootstrap.js
grunt-bower copying bower_components/bootstrap/dist/css/bootstrap.css -> public/bootstrap/bootstrap.css
/Users/hoytk/git/titanium_ui/node_modules/grunt-bower-task/node_modules/bower/node_modules/tmp/lib/tmp.js:261
throw err;
    ^
Error: ENOENT, no such file or directory 'bower_components/bootstrap/dist/fonts/*'

It seems grunt-bower-task can't handle ./dist/fonts/*, but I assume there's something simple I'm missing. Here is my Gruntfile.js:

module.exports = function(grunt) {
    // Project configuration
    grunt.initConfig({
            pkg: grunt.file.readJSON('package.json'),
            bower: {
                    install: {
                            options: {
                                    targetDir: './public',
                                    verbose: true
                            }
                    }
            }
    });

    // Load bower task plugin
    grunt.loadNpmTasks('grunt-bower-task');

    // The default task - install the bower dependencies
    grunt.registerTask('default', ['bower:install']);
}

Upvotes: 4

Views: 2062

Answers (1)

CWSpear
CWSpear

Reputation: 3270

Bower does not support * in their main file definition (which is how this task knows which files to copy over, etc).

I believe they are aware at it over at Bootstrap, but it will still a glob in 3.0.2. They were also trying to get Bower (or maybe it's the fault of the specific task?) to support globs.

Until then, there is no good solution. Either update Bootstrap's bower.json (to list each font explicitly) (note that bower.json will probably get overwritten next time there's an update) or copy the files manually :-(

(Note that you may have to change .bower.json in Bootstrap if you go that path (a hidden file))

Upvotes: 2

Related Questions