ck86 / gulp-bower-files

Build gulp.src() of your bower packages main files.
80 stars 13 forks source link

Load ".bower.json" configuration file #11

Closed bclozel closed 10 years ago

bclozel commented 10 years ago

Bower generates ".bower.json" files, by basically adding metadata to regular bower.json files. But Bower seems to generate those files even if bower.json, package.json nor component.json files exist. This could fix many cases from #9 and also rely on Bower's ability to figure out clever defaults.

bclozel commented 10 years ago

I'm actually considering putting ".bower.json" fisrt in the list or add "component.json" in the list, since many libs are using a component.js file (picked up by bower, which generates a proper .bower.json file). The problem is, those libraries also use package.json for their own build with metadata that has nothing to do with the actual bower lib.

So the current state of this PR is not good enough for many cases. What do you think?

ck86 commented 10 years ago

I don't know what order should be the best one. I would say that ".bower.json" is after the package.json and if you think we should handle component.json too, add it as the last one and I will merge.

bclozel commented 10 years ago

I've run into issues with components like "zeroclipboard": "1.1.7" - they've got a component.json file but their package.json is not the one used by bower.

With some tests, it looks like this order is the most resilient:

path.join(dependencyConfig.basePath, ".bower.json"),
path.join(dependencyConfig.basePath, "bower.json"),
path.join(dependencyConfig.basePath, "package.json"),
path.join(dependencyConfig.basePath, "component.json")

Since Bower is not only reading but also guessing if files are using the right format (see this issue), then maybe our best bet is to read ".bower.json" first.

ck86 commented 10 years ago

OK, make another commit and I will merge.

bclozel commented 10 years ago

Hi there, I squashed my previous commit, so it's all there. Thanks a lot for this library!