Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function watchComponents() {
console.log('Watching Components…');
watch([
path.resolve(__PATHS__.ui, '**/*.{md,yml}')
]).on('change', e => {
let sitemap = require('app_modules/site/navigation/sitemap').default;
let routes = sitemap.getFlattenedRoutes().filter(route => route.component);
routes.forEach(route => {
if (new RegExp(_.escapeRegExp(route.component.path)).test(e.path)) {
// Recreate the component module which will cause webpack
// to recompile and reload the browser
pageCompiler.createComponentPage(route, route.component, err => {
if (err) return console.log(err);
});
}
});
});
}
export function watcher(conf, state) {
const paths = conf.get('paths');
const options = conf.get('options');
const eventEmitter = conf.get('eventEmitter');
let debugMode = options.tools.debugMode || false;
var watcherInstance = glob_watcher(paths.toWatch).on('all', (event, _path) => {
_watch(conf, state, event, _path, debugMode);
});
eventEmitter.on('theme:stream:stop', function (data) {
watcherInstance.close();
});
}