Commit d49cc108 authored by Dan Allen's avatar Dan Allen

integrate watch into Gulp task function; rename exec argument to call

parent 40f29771
Pipeline #41660276 failed with stages
in 4 minutes and 59 seconds
......@@ -22,33 +22,29 @@ const lintTask = task({
name: 'lint',
desc: 'Lint JavaScript files using eslint (JavaScript Standard profile)',
opts: sharedOpts,
exec: lint(glob.sourceFiles),
call: lint(glob.sourceFiles),
})
const formatTask = task({
name: 'format',
desc: 'Format JavaScript files using prettier (JavaScript Standard profile)',
opts: sharedOpts,
exec: format(glob.sourceFiles),
})
const testRunTask = task({
name: 'test:run',
exec: test(glob.testFiles, process.env.COVERAGE === 'true' || process.env.CI),
call: format(glob.sourceFiles),
})
const testTask = task({
name: 'test',
desc: 'Run the test suite',
opts: Object.assign({}, sharedOpts, { '--watch': 'Watch files and run the test suite whenever a file is changed' }),
exec: opts.watch ? () => watch(glob.sourceFiles, { ignoreInitial: false }, testRunTask) : testRunTask,
opts: { ...sharedOpts, '--watch': 'Watch files and run the test suite whenever a file is changed' },
call: test(glob.testFiles, process.env.COVERAGE === 'true' || process.env.CI),
loop: opts.watch ? glob.sourceFiles : false,
})
const buildTask = task({
name: 'build',
desc: 'Run the test suite followed by the linter',
opts: sharedOpts,
exec: series(testTask, lintTask),
call: series(testTask, lintTask),
})
module.exports = exportTasks(buildTask, lintTask, formatTask, testTask)
'use strict'
const metadata = require('undertaker/lib/helpers/metadata')
const { watch } = require('gulp')
module.exports = ({ name, desc, opts, exec: fn }) => {
module.exports = ({ name, desc, opts, call: fn, loop }) => {
if (name) {
const displayName = fn.displayName
if (displayName === '<series>' || displayName === '<parallel>') {
......@@ -10,6 +11,13 @@ module.exports = ({ name, desc, opts, exec: fn }) => {
}
fn.displayName = name
}
if (loop) {
const delegate = fn
name = delegate.displayName
delegate.displayName = `${name}:loop`
fn = () => watch(loop, { ignoreInitial: false }, delegate)
fn.displayName = name
}
if (desc) fn.description = desc
if (opts) fn.flags = opts
return fn
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment