From b8a552a6cfd42562a6e7429afd95cf2399d99990 Mon Sep 17 00:00:00 2001 From: Colin Rotherham Date: Wed, 8 Mar 2023 20:58:38 +0000 Subject: [PATCH] Move lint task calls to watch task Helps reduce duplication in `gulpfile.mjs` once we start to move directory and file path configs over --- gulpfile.mjs | 16 ++++------------ tasks/gulp/watch.mjs | 15 +++++++++++---- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/gulpfile.mjs b/gulpfile.mjs index 18259902eca..53f7142c4af 100644 --- a/gulpfile.mjs +++ b/gulpfile.mjs @@ -15,10 +15,7 @@ import { npmScriptTask } from './tasks/run.mjs' * Runs JavaScript code quality checks, documentation, compilation */ gulp.task('scripts', gulp.series( - gulp.parallel( - npmScriptTask('lint:js'), - compileJavaScripts - ), + compileJavaScripts, npmScriptTask('build:jsdoc') )) @@ -27,10 +24,7 @@ gulp.task('scripts', gulp.series( * Runs Sass code quality checks, documentation, compilation */ gulp.task('styles', gulp.series( - gulp.parallel( - npmScriptTask('lint:scss'), - compileStylesheets - ), + compileStylesheets, npmScriptTask('build:sassdoc') )) @@ -41,10 +35,8 @@ gulp.task('styles', gulp.series( gulp.task('build:public', gulp.series( clean, copyAssets, - compileJavaScripts, - compileStylesheets, - npmScriptTask('build:jsdoc'), - npmScriptTask('build:sassdoc') + 'scripts', + 'styles' )) /** diff --git a/tasks/gulp/watch.mjs b/tasks/gulp/watch.mjs index 33b8b31274c..d185d94ac38 100644 --- a/tasks/gulp/watch.mjs +++ b/tasks/gulp/watch.mjs @@ -2,12 +2,13 @@ import gulp from 'gulp' import slash from 'slash' import { paths } from '../../config/index.js' +import { npmScriptTask } from '../run.mjs' /** * Watch task * During development, this task will: - * - run `gulp styles` when `.scss` files change - * - run `gulp scripts` when `.mjs` files change + * - lint and run `gulp styles` when `.scss` files change + * - lint and run `gulp scripts` when `.mjs` files change * * @returns {Promise} Array from file system watcher objects */ @@ -18,12 +19,18 @@ export function watch () { `${slash(paths.app)}/**/*.scss`, `${slash(paths.src)}/govuk/**/*.scss`, `!${slash(paths.src)}/govuk/vendor/*` - ], gulp.series('styles')), + ], gulp.parallel( + npmScriptTask('lint:scss'), + 'styles' + )), gulp.watch([ 'jsdoc.config.js', `${slash(paths.src)}/govuk/**/*.mjs` - ], gulp.series('scripts')) + ], gulp.parallel( + npmScriptTask('lint:js'), + 'scripts' + )) ]) }