UNPKG

turbo-gulp

Version:

Gulp tasks to boost high-quality projects.

31 lines (30 loc) 923 B
import gulpPug from "gulp-pug"; import { Minimatch } from "minimatch"; import { asString, join } from "../utils/matcher"; /** * Return a list of sources, prefixed by "from" */ export function getSources({ files, from }) { return files.map((val) => asString(join(from, new Minimatch(val)))); } export function buildPug(gulp, options) { return gulp .src(getSources(options), { base: options.from }) .pipe(gulpPug(options.pugOptions)) .pipe(gulp.dest(options.to)); } /** * Generate a task to build pug files */ export function generateTask(gulp, options) { const task = function () { return buildPug(gulp, options); }; task.displayName = "_build:pug"; return task; } export function watch(gulp, options) { const buildTask = generateTask(gulp, options); const sources = getSources(options); return gulp.watch(sources, { cwd: options.from }, buildTask); }