From 8cc0f65051eca668603ff625a777e67dc44af5ee Mon Sep 17 00:00:00 2001 From: Colin Rotherham Date: Fri, 31 Mar 2023 11:21:26 +0100 Subject: [PATCH] Restore watch task `gulp.parallel()` for CLI logging --- app/tasks/watch.mjs | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/app/tasks/watch.mjs b/app/tasks/watch.mjs index 350109b27c..3fba424a31 100644 --- a/app/tasks/watch.mjs +++ b/app/tasks/watch.mjs @@ -1,4 +1,5 @@ import chokidar from 'chokidar' +import gulp from 'gulp' import slash from 'slash' import { paths } from '../../config/index.js' @@ -22,22 +23,18 @@ export function watch () { `${slash(paths.root)}/sassdoc.config.yaml`, `${slash(paths.app)}/src/**/*.scss`, `${slash(paths.src)}/govuk/**/*.scss` - ], { ignored, ignoreInitial: true }, async function watch () { - await Promise.all([ - npm.run('lint:scss'), - styles - ]) - }), + ], { ignored, ignoreInitial: true }, gulp.parallel( + npm.script('lint:scss'), + styles + )), onEvent([ `${slash(paths.root)}/jsdoc.config.js`, `${slash(paths.src)}/govuk/**/*.mjs` - ], { ignored, ignoreInitial: true }, async function watch () { - await Promise.all([ - npm.run('lint:js'), - scripts - ]) - }) + ], { ignored, ignoreInitial: true }, gulp.parallel( + npm.script('lint:js'), + scripts + )) ]) } @@ -46,7 +43,7 @@ export function watch () { * * @param {string[]} paths - Paths to watch * @param {import('chokidar').WatchOptions} options - * @param {() => Promise} taskFn - File event callback + * @param {import('gulp').TaskFunction} taskFn - Task function * @returns {import('chokidar').FSWatcher} File system watcher */ function onEvent (paths, options, taskFn) { @@ -63,16 +60,13 @@ function onEvent (paths, options, taskFn) { } // 2. Task runs are ignored when running - async function throttle () { + function throttle () { if (running) { return } running = true - - await taskFn() - .then(complete) - .catch(complete) + taskFn(complete) } // 3. Task runs can resume when complete