-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
33 lines (28 loc) · 900 Bytes
/
index.js
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
28
29
30
31
32
33
var gutil = require('gulp-util');
var through = require('through2');
var compile = require('dresscodejs/lib/DressCode');
var pluginName = 'gulp-dresscode';
module.exports = function (opts) {
opts = opts || {};
return through.obj(function (file, enc, cb) {
if (file.isNull()) {
cb(null, file);
return;
}
if (file.isStream()) {
cb(new gutil.PluginError(pluginName, 'Streaming not supported'));
return;
}
compile(file.path, null, opts.debug)
.then(function (text) {
file.contents = new Buffer(text);
cb(null, file);
})
.catch(function (err) {
cb(new gutil.PluginError(pluginName, err, {
fileName: file.path,
showProperties: false
}));
});
});
};