forked from frontendfriends/gulp-combine-mq
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
43 lines (31 loc) · 816 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
35
36
37
38
39
40
41
42
43
'use strict';
var path = require('path'),
gutil = require('gulp-util'),
through = require('through2'),
combineMq = require('combine-mq');
var PLUGIN_NAME = 'gulp-combine-mq';
module.exports = function(options) {
options = options || {
beautify: true
};
return through.obj(function(file, enc, cb) {
if(file.isNull()) {
return cb();
}
if(file.isStream()) {
this.emit('error', new gutil.PluginError(PLUGIN_NAME, 'Streaming not supported'));
return cb();
}
if(file.isBuffer()) {
var processed = combineMq.parseCssString(file.contents.toString(), {
beautify: options.beautify
});
if(options.showLog) {
gutil.log(PLUGIN_NAME, gutil.colors.green('✔ ') + file.relative);
}
file.contents = new Buffer(processed);
this.push(file);
return cb();
}
});
};