-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
41 lines (33 loc) · 909 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
(function(){
"use strict";
var PluginError = require('plugin-error'),
through = require('through2'),
cssjanus = require('cssjanus'),
_ = require('lodash');
module.exports = function (config) {
config = _.defaults({}, config, {
swapLtrRtlInUrl: false,
swapLeftRightInUrl: false,
cssjanus: cssjanus
});
return through.obj(function (file, enc, cb) {
if (file.isNull()) {
this.push(file);
return cb();
}
if (file.isStream()) {
this.emit('error', new PluginError('gulp-cssjanus', 'Streaming not supported'));
return cb();
}
var ltrCss = file.contents.toString();
var rtlCss = config.cssjanus.transform(
ltrCss,
config.swapLtrRtlInUrl,
config.swapLeftRightInUrl
);
file.contents = new Buffer(rtlCss);
this.push(file);
cb();
});
};
})();