Created
September 21, 2014 22:59
-
-
Save jxnblk/9aeec4bb844733ccce0a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
var through = require('through2'); | |
var gutil = require('gulp-util'); | |
module.exports = function() { | |
var transform = function(file, enc, cb) { | |
var name = file.relative.split('.')[0]; | |
var contents = String(file.contents).replace(/\r?\n|\r/g, ' '); | |
// Build SVG | |
var svg = '<svg id="' + name + '" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" fill="currentcolor">\n' + | |
' <path d="' + contents + '"></path>\n' + | |
'</svg>'; | |
file.contents = new Buffer(svg); | |
file.path = gutil.replaceExtension(file.path, '.svg'); | |
console.log(file.relative); | |
this.push(file); | |
cb(); | |
}; | |
return through.obj(transform); | |
}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment