diff --git a/lib/detect-dependencies.js b/lib/detect-dependencies.js index 0037af7..22c53e9 100644 --- a/lib/detect-dependencies.js +++ b/lib/detect-dependencies.js @@ -143,36 +143,38 @@ function gatherInfo(config) { } } - var mains = findMainFiles(config, component, componentConfigFile); - var fileTypes = _.chain(mains).map($.path.extname).unique().value(); + if (componentConfigFile) { + var mains = findMainFiles(config, component, componentConfigFile); + var fileTypes = _.chain(mains).map($.path.extname).unique().value(); - dep.main = mains; - dep.type = fileTypes; - dep.name = componentConfigFile.name; + dep.main = mains; + dep.type = fileTypes; + dep.name = componentConfigFile.name; - var depIsExcluded = _.find(config.get('exclude'), function (pattern) { - return $.path.join(config.get('bower-directory'), component).match(pattern); - }); + var depIsExcluded = _.find(config.get('exclude'), function (pattern) { + return $.path.join(config.get('bower-directory'), component).match(pattern); + }); - if (dep.main.length === 0 && !depIsExcluded) { - // can't find the main file. this config file is useless! - warnings.push(component + ' was not injected in your file.'); - warnings.push( - 'Please go take a look in "' - + $.path.join(config.get('bower-directory'), component) - + '" for the file you need, then manually include it in your file.'); + if (dep.main.length === 0 && !depIsExcluded) { + // can't find the main file. this config file is useless! + warnings.push(component + ' was not injected in your file.'); + warnings.push( + 'Please go take a look in "' + + $.path.join(config.get('bower-directory'), component) + + '" for the file you need, then manually include it in your file.'); - config.set('warnings', warnings); - return; - } + config.set('warnings', warnings); + return; + } - if (componentConfigFile.dependencies) { - dep.dependencies = componentConfigFile.dependencies; + if (componentConfigFile.dependencies) { + dep.dependencies = componentConfigFile.dependencies; - _.each(componentConfigFile.dependencies, gatherInfo(config)); - } + _.each(componentConfigFile.dependencies, gatherInfo(config)); + } - config.get('global-dependencies').set(component, dep); + config.get('global-dependencies').set(component, dep); + } }; } @@ -277,7 +279,7 @@ var eliteDependencies = [ * @param {string} fileType the type of file to prioritize * @return {array} the sorted items of 'path/to/main/files.ext' sorted by type */ - function prioritizeDependencies(config, fileType) { +function prioritizeDependencies(config, fileType) { var eliteDependenciesCaught = []; var dependencies = mergeSort( @@ -292,7 +294,7 @@ var eliteDependencies = [ return true; } }) - ).map($.propprop('main')); + ).map($.propprop('main')); eliteDependenciesCaught. forEach(function (dependency) { @@ -300,12 +302,12 @@ var eliteDependencies = [ }); return _ - (dependencies). - flatten(). - value(). - filter(function (main) { - return $.path.extname(main) === fileType; - }); + (dependencies). + flatten(). + value(). + filter(function (main) { + return $.path.extname(main) === fileType; + }); }