Add support for multiple tasks on file change

This commit is contained in:
Nick Krichevsky 2018-06-28 19:39:01 -04:00
parent 4580d8c2fa
commit 3249c27e34

View file

@ -30,9 +30,9 @@ const TWIG_OUT_DIR = "spectabular/twig/";
//Map the various directories to the gulp tasks //Map the various directories to the gulp tasks
const WATCH_MAPPINGS = { const WATCH_MAPPINGS = {
[TS_SRC_DIR]: "typescript", [TS_SRC_DIR]: ["typescript-lint", "typescript"],
[SASS_SRC_DIR]: "sass", [SASS_SRC_DIR]: ["sass"],
[TWIG_SRC_DIR]: "twig" [TWIG_SRC_DIR]: ["twig"],
}; };
let isProdBuild = yargs.argv.hasOwnProperty("prod"); let isProdBuild = yargs.argv.hasOwnProperty("prod");
@ -53,11 +53,11 @@ gulp.task("clean", () => {
gulp.task("watch", () => { gulp.task("watch", () => {
Object.keys(WATCH_MAPPINGS).forEach((dir) => { Object.keys(WATCH_MAPPINGS).forEach((dir) => {
let globbedPath = path.join(dir, "*"); let globbedPath = path.join(dir, "*");
let taskName = WATCH_MAPPINGS[dir]; let tasks = WATCH_MAPPINGS[dir];
let watchTask = gulp.watch(globbedPath, [taskName]); let watchTask = gulp.watch(globbedPath, tasks);
watchTask.on("change", (file) => { watchTask.on("change", (file) => {
let relativePath = path.relative(__dirname, file.path); let relativePath = path.relative(__dirname, file.path);
log(`[${chalk.blue(taskName)}] Change detected: ${chalk.green(relativePath)}`); log(`[${chalk.blue(tasks.join(", "))}] Change detected: ${chalk.green(relativePath)}`);
}); });
}); });
}); });