UNPKG

549 BJavaScriptView Raw
1/*
2 * pub-server watch-sources.js
3 *
4 * copyright 2015, Jurgen Leschner - github.com/jldec - MIT license
5 */
6
7var watch = require('./watch');
8
9module.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();
19 });
20 src._watching = true; // see generator/update
21 }
22 });
23}