Skip to content

Instantly share code, notes, and snippets.

@renoirb
Forked from wspringer/bower.coffee
Last active September 7, 2015 02:54
Show Gist options
  • Save renoirb/eaa6f17b08969c7a8dae to your computer and use it in GitHub Desktop.
Save renoirb/eaa6f17b08969c7a8dae to your computer and use it in GitHub Desktop.
Bower support for Metalsmith
/**
* Attempt to port into plain JavaScript bower.coffee MetalSmith plugin and configure it.
*
* source: https://gist.github.com/wspringer/5f404813fc9a306b8c80
**/
var lib = require('bower-files')()
,basename = require('path').basename
,readFileSync = require('fs').readFileSync;
module.exports = function(files, metalsmith, done) {
var include;
include = function(root, included) {
var contents, file, i, len, results;
results = [];
for (i = 0, len = included.length; i < len; i++) {
file = included[i];
contents = readFileSync(file);
results.push(files[root + "/" + (basename(file))] = {
contents: contents
});
}
return results;
};
include('css', lib.self().ext('css').files);
include('js', lib.self().ext('js').files);
include('fonts', lib.self().ext(['eot', 'otf', 'ttf', 'woff']).files);
return done();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment