From 71d9b14b4b5625529722f987fa2a85a746055e3b Mon Sep 17 00:00:00 2001 From: Stephen Sawchuk Date: Mon, 12 Aug 2013 12:13:24 -0400 Subject: [PATCH] fixes #18. --- tasks/bower-install.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/tasks/bower-install.js b/tasks/bower-install.js index 85e507f..9d25465 100644 --- a/tasks/bower-install.js +++ b/tasks/bower-install.js @@ -29,13 +29,30 @@ var findBowerJSON = function () { }; +/** + * Try to use a `.bowerrc` file to find a custom directory. If it doesn't exist, + * we're going with "bower_components". + * + * @ return {string} the path to the bower component directory + */ +var findBowerDirectory = function () { + var directory = 'bower_components'; + + if (grunt.file.isFile('.bowerrc')) { + directory = grunt.file.readJSON('.bowerrc').directory || 'bower_components'; + } + + return directory; +}; + + module.exports = function (grunt) { grunt.registerMultiTask('bower-install', 'Inject all components in your HTML file.', function () { this.requiresConfig(['bower-install', this.target, 'html']); wiredep({ - directory: grunt.file.readJSON('.bowerrc').directory || 'bower_components', + directory: findBowerDirectory(), bowerJson: findBowerJSON(), ignorePath: this.data.ignorePath, htmlFile: this.data.html