Skip to content

Commit

Permalink
Restore watch task gulp.parallel() for CLI logging
Browse files Browse the repository at this point in the history
  • Loading branch information
colinrotherham committed Apr 11, 2023
1 parent 46ff435 commit 8cc0f65
Showing 1 changed file with 12 additions and 18 deletions.
30 changes: 12 additions & 18 deletions app/tasks/watch.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import chokidar from 'chokidar'
import gulp from 'gulp'
import slash from 'slash'

import { paths } from '../../config/index.js'
Expand All @@ -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
))
])
}

Expand All @@ -46,7 +43,7 @@ export function watch () {
*
* @param {string[]} paths - Paths to watch
* @param {import('chokidar').WatchOptions} options
* @param {() => Promise<void>} taskFn - File event callback
* @param {import('gulp').TaskFunction} taskFn - Task function
* @returns {import('chokidar').FSWatcher} File system watcher
*/
function onEvent (paths, options, taskFn) {
Expand All @@ -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
Expand Down

0 comments on commit 8cc0f65

Please sign in to comment.