-
Notifications
You must be signed in to change notification settings - Fork 99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New files watching in subfolders doesn't work #29
Comments
This is strange. If you already have this folder with files and add file to subfolder, gaze seems to catch |
Your workaround works, but it is not really useful when we have a folder structure with big (and unknown) number of nested levels. You might need to forward this issue to gaze folks I think. |
I would like to confirm this as well. This task does not pick up newly created files in a subfolder: var gulp = require('gulp');
var watch = require('gulp-watch');
gulp.task('watch', function() {
watch({ glob: 'app/views/less/**/*.less' }, function() {
console.error('something changed');
});
}); |
This will be fixed in referenced issue in gaze. |
This is what I settled on until this works properly: var gulp = require('gulp');
var watch = require('gulp-watch');
var through2 = require('through2');
var livereload = require('gulp-livereload');
var mpath = require('path');
gulp.task('watch', function() {
var lrServer = livereload();
watch({
glob: [
'app/views/less/**',
'app/views/js/**',
'app/views/jade/**',
'!app/views/js/node_modules'
],
read: false
}).pipe(through2.obj(function(file, enc, done) {
var ext = mpath.extname(file.path);
switch (ext) {
case '.less':
gulp.task('css');
break;
case '.js':
gulp.task('javascript');
break;
case '.jade':
lrServer.changed(file.path);
break;
}
this.push(file);
done();
}));
}); |
Is there a reason, that you don't use different watches for file? var gulp = require('gulp');
var watch = require('gulp-watch');
var livereload = require('gulp-livereload');
gulp.task('watch', function() {
var lrServer = livereload();
watch({ glob: [ 'app/views/less/**' ] }, ['css']);
watch({ glob: [ 'app/views/js/**', '!app/views/js/node_modules' ] }, ['javascript']);
watch({ glob: [ 'app/views/jade/**' ] }).on('data', function (file) {
lrServer.changed(file.path);
});
}); |
For anyone who is still waiting for this to get fixed in gaze, I built a small module called glob-expander that acts as a partial workaround. It will pick up new files in any existing directories. Unfortunately, it doesn't pick up directories that have been added after watch runs, but it's better than explicitly listing out all of your existing folders. @artch's original example can be re-written as such with this new package: var gulp = require('gulp'),
watch = require('gulp-watch'),
expandGlob = require('glob-expander');
gulp.task('default', function () {
watch({glob: expandGlob('subfolder/**/*.txt'), silent: false, verbose: true})
}) Note that I'm only advocating this as a temporary workaround until gaze fixes their issue. YMMV |
Did you check [email protected] (gulp-watch uses 0.5.x)? Would it fix it for you? |
I just substituted [email protected] for 0.5.x underneath glob-watching, and gulp.watch fails silently (no effect). |
So this isn't still handled in gaze 0.6.x as well? |
Steps to reproduce:
npm install gulp gulp-watch
Create local
subfolder
andsubfolder/subsubfolder
Put
gulpfile.js
to the root folder:Run
gulp
from the root folder.Put new file
1.txt
tosubfolder/subsubfolder
. It does not invoke a watcher, while it should.The text was updated successfully, but these errors were encountered: