forked from github.com/GenderDysphoria.fyi
Site JS is now compiled inside of content. No more gulp streams.
This commit is contained in:
@@ -1,31 +0,0 @@
|
||||
|
||||
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);
|
||||
});
|
||||
};
|
||||
@@ -1,32 +0,0 @@
|
||||
|
||||
const through = require('./through');
|
||||
const log = require('fancy-log');
|
||||
const { get } = require('lodash');
|
||||
|
||||
module.exports = exports = function debug (...targets) {
|
||||
return through(async (stream, file) => {
|
||||
var data;
|
||||
const { path, relative, base, basename, extname } = file;
|
||||
|
||||
if (targets.length === 1 && Array.isArray(targets[0])) {
|
||||
targets = targets[0];
|
||||
}
|
||||
|
||||
if (targets.length) {
|
||||
data = targets.reduce((result, target) => {
|
||||
if (target === 'contents') {
|
||||
result.contents = file.contents.toString();
|
||||
return result;
|
||||
}
|
||||
|
||||
result[target] = get(file, target);
|
||||
return result;
|
||||
}, {});
|
||||
} else {
|
||||
data = { ...file, path, relative, base, basename, extname };
|
||||
}
|
||||
log(data);
|
||||
stream.push(file);
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
|
||||
const filter = require('gulp-filter');
|
||||
|
||||
module.exports = exports = function filter2 (pattern, options) {
|
||||
if (pattern instanceof RegExp) {
|
||||
return filter((file) => pattern.test(file.path), options);
|
||||
}
|
||||
|
||||
return filter(pattern, options);
|
||||
};
|
||||
|
||||
exports.not = function notfilter2 (pattern, options) {
|
||||
if (pattern instanceof RegExp) {
|
||||
return filter((file) => !pattern.test(file.path), options);
|
||||
}
|
||||
|
||||
throw new Error('filter.not only takes regular expressions');
|
||||
};
|
||||
@@ -1,27 +0,0 @@
|
||||
const through = require('./through');
|
||||
const sortBy = require('lodash/sortBy');
|
||||
|
||||
function sleep (ms) {
|
||||
return new Promise((resolve) => setTimeout(resolve, ms));
|
||||
}
|
||||
|
||||
module.exports = exports = function (iteratees) {
|
||||
var files = [];
|
||||
|
||||
return through(
|
||||
async (stream, file) => {
|
||||
if (file.isNull()) return;
|
||||
|
||||
files.push(file);
|
||||
},
|
||||
async (stream) => {
|
||||
const queue = sortBy(files, iteratees);
|
||||
files = null;
|
||||
|
||||
for (const file of queue) {
|
||||
stream.push(file);
|
||||
await sleep(100);
|
||||
}
|
||||
},
|
||||
);
|
||||
};
|
||||
@@ -1,19 +0,0 @@
|
||||
|
||||
const log = require('fancy-log');
|
||||
var through = require('through2');
|
||||
|
||||
module.exports = exports = function asyncthrough (...args) {
|
||||
const [ fn, donefn ] = args;
|
||||
|
||||
args[0] = function (file, enc, next) {
|
||||
fn(this, file, enc).then(() => next(), (err) => { log.error(err, 'Error thrown'); next(err); });
|
||||
};
|
||||
|
||||
if (donefn) {
|
||||
args[1] = function (next) {
|
||||
donefn(this).then(() => next(), (err) => { log.error(err, 'Error thrown'); next(err); });
|
||||
};
|
||||
}
|
||||
|
||||
return through.obj(...args);
|
||||
};
|
||||
Reference in New Issue
Block a user