-
-
Save renoirb/eaa6f17b08969c7a8dae to your computer and use it in GitHub Desktop.
Bower support for Metalsmith
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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