mirror of
https://github.com/boostorg/unordered-ui-bundle.git
synced 2026-01-19 04:42:15 +00:00
- upgrade to Gulp 4 - refactor tasks to use Gulp 4 task system - switch from map-stream to through2.obj - switch from fs to fs-extra - fix Gulp prettier+eslint integration - rename tasks
24 lines
608 B
JavaScript
24 lines
608 B
JavaScript
'use strict'
|
|
|
|
const chokidar = require('chokidar')
|
|
const connect = require('gulp-connect')
|
|
|
|
module.exports = (serveDir, opts = {}) => (done) => {
|
|
const watch = opts.watch
|
|
delete opts.watch
|
|
opts = Object.assign({ root: serveDir }, opts)
|
|
let onStart
|
|
if (watch && watch.src && watch.onChange) {
|
|
onStart = () =>
|
|
chokidar
|
|
.watch(watch.src, { ignoreInitial: true })
|
|
.on('add', watch.onChange)
|
|
.on('change', watch.onChange)
|
|
.on('unlink', watch.onChange)
|
|
}
|
|
connect.server(opts, function () {
|
|
this.server.on('close', done)
|
|
if (onStart) onStart()
|
|
})
|
|
}
|