-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
27 lines (22 loc) · 656 Bytes
/
index.js
File metadata and controls
27 lines (22 loc) · 656 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
'use strict';
var through = require('through2');
var PluginError = require('plugin-error');
var Breakdance = require('breakdance');
module.exports = function(options) {
options = options || {};
var bd = options.breakdance || new Breakdance(options);
return through.obj(function(file, enc, next) {
if (file.isNull()) {
next(null, file);
return;
}
try {
file.contents = new Buffer(bd.render(file.contents.toString(), options));
file.extname = '.md';
} catch (err) {
this.emit('error', new PluginError('gulp-breakdance', err, {fileName: file.path}));
return;
}
next(null, file);
});
};