turbo-gulp
Version:
Gulp tasks to boost high-quality projects.
30 lines (29 loc) • 777 B
JavaScript
import del from "del";
import { Minimatch } from "minimatch";
import { posix as path } from "path";
import * as matcher from "../utils/matcher";
/**
* Return a list of files, prefixed by "base"
*/
function getFiles(options) {
const files = [];
if (options.dirs !== undefined) {
for (const dir of options.dirs) {
files.push(path.join(options.base, dir));
}
}
if (options.files !== undefined) {
for (const file of options.files) {
files.push(matcher.asString(matcher.join(options.base, new Minimatch(file))));
}
}
return files;
}
/**
* Generate a task to clean files
*/
export function generateTask(gulp, options) {
return async function () {
return del(getFiles(options));
};
}