mirror of
https://github.com/GenderDysphoria/GenderDysphoria.fyi.git
synced 2025-01-31 07:16:17 +00:00
32 lines
698 B
JavaScript
32 lines
698 B
JavaScript
|
|
const through = require('./through');
|
|
const crass = require('crass');
|
|
const PluginError = require('plugin-error');
|
|
|
|
module.exports = exports = function (options) {
|
|
options = {
|
|
pretty: false,
|
|
o1: true,
|
|
...options,
|
|
};
|
|
|
|
return through(async (stream, file) => {
|
|
if (file.isNull()) {
|
|
stream.push(file);
|
|
return;
|
|
}
|
|
|
|
try {
|
|
var parsed = crass.parse(file.contents.toString());
|
|
parsed = parsed.optimize({ O1: !!options.o1 });
|
|
if (options.pretty) parsed = parsed.pretty();
|
|
|
|
file.contents = Buffer.from(parsed.toString());
|
|
} catch (err) {
|
|
this.emit('error', new PluginError('gulp-crass', err));
|
|
}
|
|
|
|
stream.push(file);
|
|
});
|
|
};
|