Only watch indexed files

pull/21833/head
Luke Barnard 2017-05-08 16:29:53 +01:00
parent 574c836941
commit 9af9603373
1 changed files with 3 additions and 2 deletions

View File

@ -7,6 +7,7 @@ var chokidar = require('chokidar');
var componentIndex = path.join('src', 'component-index.js'); var componentIndex = path.join('src', 'component-index.js');
var componentsDir = path.join('src', 'components'); var componentsDir = path.join('src', 'components');
var componentGlob = '**/*.js';
function reskindex() { function reskindex() {
var header = args.h || args.header; var header = args.h || args.header;
@ -36,7 +37,7 @@ function reskindex() {
strm.write("module.exports.components = {};\n"); strm.write("module.exports.components = {};\n");
} }
var files = glob.sync('**/*.js', {cwd: componentsDir}).sort(); var files = glob.sync(componentGlob, {cwd: componentsDir}).sort();
for (var i = 0; i < files.length; ++i) { for (var i = 0; i < files.length; ++i) {
var file = files[i].replace('.js', ''); var file = files[i].replace('.js', '');
@ -60,7 +61,7 @@ if (!args.w) {
} }
var watchDebouncer = null; var watchDebouncer = null;
chokidar.watch('./src').on('all', (event, path) => { chokidar.watch(path.join(componentsDir, componentGlob)).on('all', (event, path) => {
if (path === componentIndex) return; if (path === componentIndex) return;
if (watchDebouncer) clearTimeout(watchDebouncer); if (watchDebouncer) clearTimeout(watchDebouncer);
watchDebouncer = setTimeout(reskindex, 1000); watchDebouncer = setTimeout(reskindex, 1000);