Add support for multiple tasks on file change
parent
4580d8c2fa
commit
3249c27e34
12
gulpfile.js
12
gulpfile.js
|
@ -30,9 +30,9 @@ const TWIG_OUT_DIR = "spectabular/twig/";
|
|||
|
||||
//Map the various directories to the gulp tasks
|
||||
const WATCH_MAPPINGS = {
|
||||
[TS_SRC_DIR]: "typescript",
|
||||
[SASS_SRC_DIR]: "sass",
|
||||
[TWIG_SRC_DIR]: "twig"
|
||||
[TS_SRC_DIR]: ["typescript-lint", "typescript"],
|
||||
[SASS_SRC_DIR]: ["sass"],
|
||||
[TWIG_SRC_DIR]: ["twig"],
|
||||
};
|
||||
|
||||
let isProdBuild = yargs.argv.hasOwnProperty("prod");
|
||||
|
@ -53,11 +53,11 @@ gulp.task("clean", () => {
|
|||
gulp.task("watch", () => {
|
||||
Object.keys(WATCH_MAPPINGS).forEach((dir) => {
|
||||
let globbedPath = path.join(dir, "*");
|
||||
let taskName = WATCH_MAPPINGS[dir];
|
||||
let watchTask = gulp.watch(globbedPath, [taskName]);
|
||||
let tasks = WATCH_MAPPINGS[dir];
|
||||
let watchTask = gulp.watch(globbedPath, tasks);
|
||||
watchTask.on("change", (file) => {
|
||||
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)}`);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue