zont / gulp-bower

MIT License
82 stars 22 forks source link

Add option to only copy files specified in "main" of bower.json file #37

Closed anwalkers closed 3 years ago

anwalkers commented 9 years ago

Add a way to have gulp-bower only copy the files specified in the bower.json "main" array. For example the angular.js bower.json file to a destination path...

{
  "name": "angular",
  "version": "1.3.15",
  "main": "./angular.js",
  "ignore": [],
  "dependencies": {
  }
}
gulp.task('bower', function () {
    return bower({src: paths.bower, dest: paths.lib, useMain: true}); //Something like this ?!?!?
});
anwalkers commented 9 years ago

Well this may not work... Some packages don't have a bower.json...

    fs.readdir(cwd, function (err, files) {
        var bowerfiles = [];
        for (index = 0; index < files.length; ++index) {
            file = files[index];
            if (file[0] !== '.') {
                filePath = cwd + '/' + file + '/bower.json';
                var bowerconfig = JSON.parse(fs.readFileSync(filePath));
                console.log(bowerconfig);
            }
        }
    });
thomaswelton commented 9 years ago

https://github.com/ck86/main-bower-files

This repo could either utilise the above package, or allow this implementation to be left to the consumer.

Tronix117 commented 8 years ago

Feature definitely needed, if the package doesn't have a bower.json, there is a overrides property that can be added in the project bower.json. As fallback, if there is no override, the whole content should be copied.