Skip to content

Commit f8dcc00

Browse files
authored
Better logging of gulp watches. (#139)
1 parent f98fd1d commit f8dcc00

File tree

1 file changed

+33
-4
lines changed

1 file changed

+33
-4
lines changed

.core/gulp.tasks.js

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -826,20 +826,49 @@ $assets: (
826826
.pipe(gulp.dest(config.dest.assets));
827827

828828
const watchFork = done => {
829+
const watchers = {};
829830
// Watch for file changes
830-
gulp.watch(config.watch.colors, gulp.task('styles:colors'));
831-
gulp.watch(config.watch.pluginAssets, gulp.task('styles:pluginAssets'));
832-
gulp.watch(config.watch.style, gulp.task('styles:compile'));
833-
gulp.watch(config.src.styleDDD, gulp.task('styles:partials'));
831+
watchers['styles:colors'] = gulp.watch(
832+
config.watch.colors,
833+
gulp.task('styles:colors'),
834+
);
835+
watchers['styles:pluginAssets'] = gulp.watch(
836+
config.watch.pluginAssets,
837+
gulp.task('styles:pluginAssets'),
838+
);
839+
watchers['styles:compile'] = gulp.watch(
840+
config.watch.style,
841+
gulp.task('styles:compile'),
842+
);
843+
watchers['styles:partials'] = gulp.watch(
844+
config.src.styleDDD,
845+
gulp.task('styles:partials'),
846+
);
834847
gulpwatch(config.watch.markup, watcher);
835848
gulpwatch(config.watch.assets, watcher);
836849
const scriptWatcher = gulp.watch(
837850
config.watch.js,
838851
gulp.parallel(task('manifest')),
839852
);
853+
854+
watchLogger(watchers);
840855
done();
841856
};
842857

858+
const watchLogger = watchers => {
859+
Object.entries(watchers).forEach(([type, watcher]) => {
860+
[
861+
['change', chalk.green(`[${type} change]`)],
862+
['add', chalk.green(`[${type} add]`)],
863+
['unlink', chalk.green(`[${type} delete]`)],
864+
].forEach(([eventName, label]) => {
865+
watcher.on(eventName, changed => {
866+
console.log(label, changed);
867+
});
868+
});
869+
});
870+
};
871+
843872
const tasks = {
844873
apidocs,
845874
local: local(),

0 commit comments

Comments
 (0)