1 | /*
|
2 | * pub-server watch-sources.js
|
3 | *
|
4 | * copyright 2015-2020, Jürgen Leschner - github.com/jldec - MIT license
|
5 | */
|
6 |
|
7 | var watch = require('./watch');
|
8 |
|
9 | module.exports = function watchSources(generator) {
|
10 | var opts = generator.opts;
|
11 | var log = opts.log;
|
12 |
|
13 | opts.sources.forEach(function(src) {
|
14 | if (src.watch && !opts['no-watch']) {
|
15 | watch(src, function(evt, path) {
|
16 | log('source %s %s', evt, path);
|
17 | src._reloadFromSource = true;
|
18 | generator.reload(); // throttled
|
19 | });
|
20 | src._watching = true; // see generator/update
|
21 | }
|
22 | });
|
23 | };
|