mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-10 10:03:21 -04:00
Merge pull request #2930 from alphagov/fix-gulp-watch
Make watch task work with new Gulp API
This commit is contained in:
37
gulpfile.js
37
gulpfile.js
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
// 1. LIBRARIES
|
// 1. LIBRARIES
|
||||||
// - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - -
|
||||||
const { src, pipe, dest, series, parallel } = require('gulp');
|
const { src, pipe, dest, series, parallel, watch } = require('gulp');
|
||||||
const stylish = require('jshint-stylish');
|
const stylish = require('jshint-stylish');
|
||||||
|
|
||||||
const plugins = {};
|
const plugins = {};
|
||||||
@@ -142,14 +142,26 @@ const images = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// Watch for changes and re-run tasks
|
const watchFiles = {
|
||||||
const watchForChanges = () => {
|
javascripts: (cb) => {
|
||||||
return watch(paths.src + 'javascripts/**/*', ['javascripts'])
|
watch([paths.src + 'javascripts/**/*'], javascripts);
|
||||||
.watch(paths.src + 'stylesheets/**/*', ['sass'])
|
cb();
|
||||||
.watch(paths.src + 'images/**/*', ['images'])
|
},
|
||||||
.watch('gulpfile.js', ['default']);
|
sass: (cb) => {
|
||||||
|
watch([paths.src + 'stylesheets/**/*'], sass);
|
||||||
|
cb();
|
||||||
|
},
|
||||||
|
images: (cb) => {
|
||||||
|
watch([paths.src + 'images/**/*'], images);
|
||||||
|
cb();
|
||||||
|
},
|
||||||
|
self: (cb) => {
|
||||||
|
watch(['gulpfile.js'], defaultTask);
|
||||||
|
cb();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const lint = {
|
const lint = {
|
||||||
'sass': () => {
|
'sass': () => {
|
||||||
return src([
|
return src([
|
||||||
@@ -171,6 +183,7 @@ const lint = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// Default: compile everything
|
// Default: compile everything
|
||||||
const defaultTask = parallel(
|
const defaultTask = parallel(
|
||||||
series(
|
series(
|
||||||
@@ -188,6 +201,16 @@ const defaultTask = parallel(
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// Watch for changes and re-run tasks
|
||||||
|
const watchForChanges = parallel(
|
||||||
|
watchFiles.javascripts,
|
||||||
|
watchFiles.sass,
|
||||||
|
watchFiles.images,
|
||||||
|
watchFiles.self
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
exports.default = defaultTask;
|
exports.default = defaultTask;
|
||||||
|
|
||||||
exports.lint = series(lint.sass, lint.js);
|
exports.lint = series(lint.sass, lint.js);
|
||||||
|
|||||||
Reference in New Issue
Block a user