Skip to content

Instantly share code, notes, and snippets.

@jxnblk
Created September 21, 2014 22:59
Show Gist options
  • Save jxnblk/9aeec4bb844733ccce0a to your computer and use it in GitHub Desktop.
Save jxnblk/9aeec4bb844733ccce0a to your computer and use it in GitHub Desktop.
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