Relative path in custom watchers (#3673)

This was missing in #3633.
This commit is contained in:
Jonas Galvez 2018-08-10 07:37:05 -03:00 committed by Clark Du
parent 8d21b60a24
commit 1842a3b5cb
2 changed files with 14 additions and 18 deletions

View File

@ -35,9 +35,11 @@ export default class Builder {
this.compilersWatching = []
this.webpackDevMiddleware = null
this.webpackHotMiddleware = null
this.filesWatcher = null
this.customFilesWatcher = null
this.nuxtRestartWatcher = null
this.watchers = {
files: null,
custom: null,
restart: null
}
this.perfLoader = null
// Helper to resolve build paths
@ -610,7 +612,7 @@ export default class Builder {
const refreshFiles = _.debounce(() => this.generateRoutesAndFiles(), 200)
// Watch for src Files
this.filesWatcher = chokidar
this.watchers.files = chokidar
.watch(patterns, options)
.on('add', refreshFiles)
.on('unlink', refreshFiles)
@ -621,7 +623,7 @@ export default class Builder {
..._.values(_.omit(this.options.build.styleResources, ['options']))
)
customPatterns = _.map(_.uniq(customPatterns), upath.normalizeSafe)
this.customFilesWatcher = chokidar
this.watchers.custom = chokidar
.watch(customPatterns, options)
.on('change', refreshFiles)
@ -631,10 +633,10 @@ export default class Builder {
})
const nuxtRestartWatch = _.concat(
this.options.watch,
this.options.watch.map(r),
path.join(this.options.rootDir, 'nuxt.config.js')
)
this.nuxtRestartWatcher = chokidar
this.watchers.restart = chokidar
.watch(nuxtRestartWatch, options)
.on('change', (event, _path) => {
const parsedPath = path.parse(_path)
@ -643,16 +645,10 @@ export default class Builder {
}
async unwatch() {
if (this.filesWatcher) {
this.filesWatcher.close()
}
if (this.customFilesWatcher) {
this.customFilesWatcher.close()
}
if (this.nuxtRestartWatcher) {
this.nuxtRestartWatcher.close()
for (const watcher in this.watchers) {
if (this.watchers[watcher]) {
this.watchers[watcher].close()
}
}
this.compilersWatching.forEach(watching => watching.close())

View File

@ -1,3 +1,3 @@
export default {
watch: ['./custom.file']
watch: ['~/custom.file']
}