-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
27 lines (27 loc) · 1.02 KB
/
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
'use strict';
const gutil = require('gulp-util');
const through = require('through2');
const pxToRem = require('./dist/pxToRem');
module.exports = (options) => {
// Какие-то действия с опциями. Например, проверка их существования,
// задание значения по умолчанию и т.д.
return through.obj(function(blobFile, enc, cb) {
// Если файл не существует
if (blobFile.isNull()) {
cb(null, blobFile);
return;
}
// Если файл представлен потоком
if (blobFile.isStream()) {
cb(new gutil.PluginError('gulp-example-plugin', 'Streaming not supported'));
return;
}
// Код плагина
let file = blobFile.contents.toString();
file = pxToRem(file,options);
blobFile.contents = new Buffer(file);
// Возвращаем обработанный файл для следующего плагина
this.push(blobFile);
cb();
});
};