-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathindex.js
34 lines (29 loc) · 867 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
34
var gutil = require('gulp-util');
var through = require('through2');
var postcss = require('postcss');
var scss = require('postcss-scss');
var stylefmt = require('stylefmt');
module.exports = function (options) {
options = options || {};
return through.obj(function (file, enc, cb) {
if (file.isNull()) {
cb(null, file);
return;
}
if (file.isStream()) {
cb(new gutil.PluginError('gulp-stylefmt', 'Streaming not supported'));
return;
}
var self = this
postcss([stylefmt(options)])
.process(file.contents.toString(), { syntax: scss })
.then(function (result) {
file.contents = new Buffer(result.css);
self.push(file);
cb();
})
.catch(function (err) {
this.emit('error', new gutil.PluginError('gulp-cssfmt', err, {fileName: file.path}));
});
});
};