taptapship/wiredep — pull request #85 by michikono (2014-07-13 08:25:24+00:00)
Title: Remove requirement that a dpendency is present

#24 references a potential use-case.

I have a project where I'm trying to use only PARTS of a bower install in a sub folder.

|--
| -- bower_components (original)
|-- bower_package_1
|-- bower_package_2
|-- bower_package_3
| -- sub_project
|-- bower_components (copied)
|-- bower_package_1
|-- bower_package_3
|-- index.html
|-- bower.json
|-- Gruntfile.js

In the Gruntfile, I do this:

sub_project: {
directory: 'sub_project/bower_components',
src: [
'sub_project/*.html',
'stylesheets/*.scss'
],
// Optional:
// ---------
cwd: 'sub_project',

The Gruntfile runs the bower install and then copies the bower packages around using a copy job. I'm hoping to see sub_project/index.html reflect only the parts that are copied in. However, right now your tool will bomb out due to the error:

`Cannot read property 'main' of undefined`

This happens on line 146 in lib/detect-dependencies.js (see change). The fix is to simply omit this block when the config file isn't found.

It is a one line change, but may have circumvent purposeful designs. An alternative is to include an or block in that if condition:

if(componentConfigFile || config.ensureDependencyInstalled) {

And set that config value to true by default.