mirror of
https://github.com/GenderDysphoria/GenderDysphoria.fyi.git
synced 2025-11-25 20:42:40 +00:00
Initial site commit
This commit is contained in:
31
gulp/lib/crass.js
Normal file
31
gulp/lib/crass.js
Normal file
@@ -0,0 +1,31 @@
|
||||
|
||||
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);
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user