gulp-io
Version:
iio's front-end build tools.
31 lines (25 loc) • 703 B
JavaScript
;
var gutil = require('gulp-util');
var through = require('through2');
var markdownGithub = require('github-markdown-preview');
module.exports = function (options) {
return through.obj(function (file, enc, cb) {
if (file.isNull()) {
cb(null, file);
return;
}
if (file.isStream()) {
cb(new gutil.PluginError('gulp-markdown', 'Streaming not supported'));
return;
}
markdownGithub(file.contents.toString(), function (err, data) {
if (err) {
cb(new gutil.PluginError('gulp-markdown', err, {fileName: file.path}));
return;
}
file.contents = new Buffer(data);
file.path = gutil.replaceExtension(file.path, '.html');
cb(null, file);
});
});
};