Watch files for changes & rebuild.
357363
function watchTask() {
    gulp.watch(config.watchers.static, copyStaticFiles);
    gulp.watch(config.watchers.css, gulp.series(lintCSS, compileSass));
    gulp.watch(config.watchers.js, gulp.series(lintJS, concatJS, copyJS));
    gulp.watch(config.watchers.drizzle, drizzleTask);
}
875121
function watchCompiler(compiler, options={}){
  let watching = false
  log('Watch Building')
  const startWatchTime = Date.now()
  const watchConfig = { // watch options:
    //aggregateTimeout: 300, // wait so long for more changes
    //poll: true // use polling instead of native watchers
    // pass a number to set the polling interval
  }

  options.onRebuild = options.onRebuild || function(){}

  return new Promise(function(res,rej){  
    //webpack watch functionality
    compiler.watch(watchConfig, function(err,stats){
      if(err)return rej(err)

      if(watching){
        log('Rebuilt '+getServerTime())
        options.onRebuild(stats)
      }else{
        watching = true
        log('Watching '+(Date.now()-startWatchTime)/1000+' seconds')
        res( this )
      }
    });
  })
}
900476
def _watch_refresh_source(self, event):
        
        self.logger.info("Sources changed...")

        try:
            self.sources = self._get_sources()
            self._render_template(self.sources)
        except:
            pass
1084265
function beginWatch() {
    let watchPaths = []
    let outputs = []

    util.each(cfgArr, function(config) {
      outputs = outputs.concat(config.output)
      watchPaths = watchPaths.concat(config.files)
      watchPaths = watchPaths.concat(config.libPaths)
    })

    chokidar
      .watch(watchPaths, {
        persistent: true,
        ignored: outputs,
        ignoreInitial: true,
        followSymlinks: true,
        usePolling: true,
        alwaysStat: false,
        interval: 100,
        atomic: true,
        ignorePermissionErrors: false
      })
      .on('change', function() {
        i = 0
        build(cfgArr[i], true)
      })
  }
1299730
function watch() {
  gulp.watch('src/pages/**/*.html').on('all', gulp.series(pages, inline, browser.reload));
  gulp.watch(['src/layouts/**/*', 'src/partials/**/*']).on('all', gulp.series(resetPages, pages, inline, browser.reload));
  gulp.watch(['../scss/**/*.scss', 'src/assets/scss/**/*.scss']).on('all', gulp.series(resetPages, sass, pages, inline, browser.reload));
  gulp.watch('src/assets/img/**/*').on('all', gulp.series(images, browser.reload));
}
218954
def _update_project_watch(config, task_presenter, results,
                          long_description, tutorial):  # pragma: no cover
    """"""
    logging.basicConfig(level=logging.INFO,
                        format='%(asctime)s - %(message)s',
                        datefmt='%Y-%m-%d %H:%M:%S')
    path = os.getcwd()
    event_handler = PbsHandler(config, task_presenter, results,
                               long_description, tutorial)
    observer = Observer()
    # We only want the current folder, not sub-folders
    observer.schedule(event_handler, path, recursive=False)
    observer.start()
    try:
        while True:
            time.sleep(1)
    except KeyboardInterrupt:
        observer.stop()
    observer.join()
1121862
function watch() {
  gulp.watch([appSrc + '/app/**/*.ts', '!' + appSrc + '/app/**/*.spec.ts']).on('change', function (path) {
    console.log('TypeScript file ' + path + ' has been changed. Compiling.');
    gulp.series(inlineTemplate, transpile, updateWatchDist)();
  });
  gulp.watch([appSrc + '/app/**/*.less', appSrc + '/assets/**/*.less']).on('change', function (path) {
    console.log(path + ' has been changed. Updating.');
    gulp.series(() => transpileMinifyLESS(path), updateWatchDist)();
  });
  gulp.watch([appSrc + '/app/**/*.html']).on('change', function (path) {
    console.log(path + ' has been changed. Updating.');
    gulp.series(inlineTemplate, transpile, updateWatchDist)();
  });
}
1186538
def sync_in(self, force=False):
        """"""
        self.log('---- Sync In ----')

        self.dstate = self.STATES.BUILDING

        for path_name in self.source_fs.listdir():

            f = self.build_source_files.instance_from_name(path_name)

            if not f:
                self.warn('Ignoring unknown file: {}'.format(path_name))
                continue

            if f and f.exists and (f.fs_is_newer or force):
                self.log('Sync: {}'.format(f.record.path))
                f.fs_to_record()
                f.record_to_objects()

        self.commit()

        self.library.search.index_bundle(self, force=True)
892354
def doc_watch():
    """"""
    try:
        from watchdog.events import FileSystemEventHandler
        from watchdog.observers import Observer
    except ImportError:
        print_failure_message('Install the watchdog package to use this task, '
                              "i.e., `pip install watchdog'.")
        raise SystemExit(1)

    class RebuildDocsEventHandler(FileSystemEventHandler):
        def __init__(self, base_paths):
            self.base_paths = base_paths

        def dispatch(self, event):
            """Dispatches events to the appropriate methods.
            :param event: The event object representing the file system event.
            :type event: :class:`watchdog.events.FileSystemEvent`
            """
            for base_path in self.base_paths:
                if event.src_path.endswith(base_path):
                    super(RebuildDocsEventHandler, self).dispatch(event)
                    # We found one that matches. We're done.
                    return

        def on_modified(self, event):
            print_failure_message('Modification detected. Rebuilding docs.')
            # # Strip off the path prefix.
            # import os
            # if event.src_path[len(os.getcwd()) + 1:].startswith(
            #         CODE_DIRECTORY):
            #     # sphinx-build doesn't always pick up changes on code files,
            #     # even though they are used to generate the documentation. As
            #     # a workaround, just clean before building.
            doc_html()
            print_success_message('Docs have been rebuilt.')

    print_success_message(
        'Watching for changes in project files, press Ctrl-C to cancel...')
    handler = RebuildDocsEventHandler(get_project_files())
    observer = Observer()
    observer.schedule(handler, path='.', recursive=True)
    observer.start()
    try:
        while True:
            time.sleep(1)
    except KeyboardInterrupt:
        observer.stop()
        observer.join()
95198
public function refreshWatched()
    {
        $timestamps = [0];
        foreach ($this->_watched as $path) {
            $timestamps[] = filemtime($path);
        }
        $this->_watchedTimestamp = max($timestamps);
    }
1351248
function watch(done) {
  var mainWatcher = gulp.watch([
    'src/**/*.js',
    'modules/**/*.js',
    'test/spec/**/*.js',
    '!test/spec/loaders/**/*.js'
  ]);
  var loaderWatcher = gulp.watch([
    'loaders/**/*.js',
    'test/spec/loaders/**/*.js'
  ]);

  connect.server({
    https: argv.https,
    port: port,
    root: './',
    livereload: true
  });

  mainWatcher.on('all', gulp.series(clean, gulp.parallel(lint, 'build-bundle-dev', test)));
  loaderWatcher.on('all', gulp.series(lint));
  done();
}
1049768
function watchModules(paths) {

    paths || (paths = []);

    if (!Array.isArray(paths)) { paths = [paths]; }

    // for all directories / files in `config.watch` array
    paths.forEach(function(watchPath) {

      // watch modules for changes
      this.watch(watchPath, function(eventPath, stat) {

        // delete from the warm cache, the next require will be fresh
        var cached = require.cache[path.resolve(eventPath)];
        var children;

        if (!cached) return;

        cached.children.forEach(function(module) {
          delete require.cache[module.id]
        });
        delete require.cache[cached.parent.id];
        delete require.cache[path.resolve(eventPath)]

      });

    }.bind(this));
  }
294772
function watchAdditional(browserify, options) {
	var changingDeps = {};
	var pending = false;
	var updating = false;

	// watchify and sharing
	var sharedCache = browserify._options.cache;
	var sharedPkgcache = browserify._options.packageCache;

	var cache_target_paths = {};
	var mcached = new mutils.Cached(browserify);

	// watchfiles in watchify
	var watchify_on_files = {};
	browserify.on('bundle', function () {
		watchify_on_files = {};
	});
	browserify.on('file', function (file) {
		// NOTE : collect watch files of watchify
		watchify_on_files[file] = true;
	});

	browserify.on('bundle', function(bundle) {
		updating = true;

		var watched = false,
			ended = false;

		// NOTE : wait until browserify._recorded is update, for when used with the default options.
		var stream = through.obj(
			function transform(row, enc, next) { this.push(row); next(); }, // no-op
			function flush(done) {
				if (checkWatchify(browserify)) {
					var full_paths = mutils.toResolvePaths([].concat(options.files).concat(options.getFiles()));

					// add require target files
					mcached.collectRequirePaths(full_paths, function (collect_file_sources) {
						var collect_full_paths = Object.keys(collect_file_sources);
						// NOTE : keep wildcard path
						watchFile(_.uniq(full_paths.concat(collect_full_paths)));

						watched = true;
						oncomplete();
					});
				} else {
					watched = true;
				}
				done();
			});
		browserify.pipeline.get('record').push(stream);

		bundle.on('error', onend);
		bundle.on('end', onend);
		function onend () {
			ended = true;
			oncomplete();
		}

		function oncomplete () {
			if (!watched || !ended) return;

			if (checkWatchify(browserify)) {
				// unwatch the duplicated files from watchify
				var target_paths = _.uniq(
					Object.keys(browserify.pipeline.get('deps')._streams[0].visited)
						.concat(Object.keys(watchify_on_files)));

				unwatch(target_paths);
				target_paths.forEach(function (path) {
					cache_target_paths[path] = true;
				});
			}

			updating = false;
		}
	});


	var w = null;
	var runner = null;

	function watchFile(paths) {
		if (w) w.close();

		// TODO : support ignored

		w = chokidar.watch(paths);
		w.setMaxListeners(0);
		w.on('error', browserify.emit.bind(browserify, 'error'));
		w.on('change', function (file) {
			invalidate(file);
		});

		runner = new DelayRunner(DELAY);
	}

	function invalidate(id) {
		if (sharedCache) delete sharedCache[id];
		if (sharedPkgcache) delete sharedPkgcache[id];
		changingDeps[id] = true;

		var emit = true;
		emit = emit && !cache_target_paths[id];
		emit = emit && _.every(watchify_on_files, function (dummy, file) { return !putils.isEqualPath(id, file); });

		if (!updating && cache_target_paths[id]) {
			// remove expired path
			delete cache_target_paths[id];
		}

		if (emit) {
			// wait for the disk/editor to quiet down first:
			if (pending) clearTimeout(pending);
			pending = setTimeout(notify, DELAY);
		}
	}

	function notify() {
		if (updating) {
			pending = setTimeout(notify, DELAY);
		} else {
			pending = false;
			browserify.emit('update', Object.keys(changingDeps));
			changingDeps = {};
		}
	}

	function unwatch(paths) {
		// NOTE : do not work w.unwatch, if after immediate add.
		//        make a delay so
		runner.run(function () { w.unwatch(paths); });
	}

	function checkWatchify(browserify) {
		// XXX : _watcher is private field. judgement using watchify is not appropriate.
		//       but only this one :(
		return !!browserify._watcher;
	}

	return browserify;
}
66446
def run_recursively_and_collect_multiple_changes(monitor, times, directory, *flags, &block)
      watch_and_run(monitor, times, true, directory, *flags, &block)
    end
113802
def watch_file(path, func, *args, **kwargs):
    
    if not path:
        raise ValueError('Please specify a file to watch')
    print('Watching "{}" for changes'.format(path))
    last_modification_time = os.path.getmtime(path)
    try:
        while True:
            time.sleep(1)
            new_modification_time = os.path.getmtime(path)
            if new_modification_time == last_modification_time:
                continue
            func(*args, **kwargs)
            last_modification_time = new_modification_time
    except KeyboardInterrupt:
        pass
880329
function watch() {
  gulp.watch(['src/**/*.js', '!src/**/README.md'],
    ['scripts', 'demos', 'components', reload]);
  gulp.watch(['src/**/*.{scss,css}'],
    ['styles', 'styles-grid', 'styletemplates', reload]);
  gulp.watch(['src/**/*.html'], ['pages', reload]);
  gulp.watch(['src/**/*.{svg,png,jpg}'], ['images', reload]);
  gulp.watch(['src/**/README.md'], ['pages', reload]);
  gulp.watch(['templates/**/*'], ['templates', reload]);
  gulp.watch(['docs/**/*'], ['pages', 'assets', reload]);
  gulp.watch(['package.json', 'bower.json', 'LICENSE'], ['metadata']);
}
1157239
function(file, event) {
    var fn = function(file) {};
    for(var i = 0; i < watchList.length; i++) {
        if(watchList[i].file === file) {
            watchers[i].on(event, fn);
            watchList[i].callback[event] = fn;
            return;
        }
    }
    throw new Error(file + " was not being watched previously");
}