-
Notifications
You must be signed in to change notification settings - Fork 357
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
Not detecting added files on OSX #20
Comments
I'm worried this might be related to #13, where I believe it's an issue with OSX >= 10.7 and this plugin. I'm still on OSX 10.6 and this test passes for me. On my todo list to upgrade and see if I can find a solution. If you get some time, could you download and run the test suite As a temporary solution, you can turn on the option: |
It's the same for me, on OS X 10.8.2. It works with forceWatchMethod: old, as suggested, but it is very slow. |
I had to install gaze "0.3.1" to get the forceWatchMethod to work reliably with the 0.2.x branch of grunt-contrib-watch on OSX 10.8 w/ macvim. |
Quick heads-up that I'm having the same problem on 10.8.2 with watch 0.2x. |
also seeing this problem on the newest version |
Thanks! If anyone has the time to look into this on OSX 10.7+ it would be very much appreciated :) |
@shama All I had to do was bump the gaze dep to 0.3.1 and grunt-contrib-watch worked fine |
I can confirm this issue on.. I noticed this also on a Windows 7 machine running the same versions as above. New files that are added to a watched folder are not picked up, however if you restart the watch task everything functions as per normal. I tried dropping the Gaze dependencies down to 0.3.1 from 0.3.2 incase it had a regression error, no dice. As well, I ran the tests on Gaze and they all passed. I should have some time tomorrow to test out Gaze 0.3.2 by itself to narrow down where the error exists. Will report back my findings.
|
@philips glad to hear it's not an issue for you! @jamie-stackhouse I would very much appreciate the help. Thanks! |
An aside... how do you do negation? I thought something like.. So, I only have access to the Windows 7 machine right now, however.. var gaze = require('gaze');
gaze(['js/**/*.js'], function(err, watcher) {
console.log(this.watched());
this.on('changed', function(filepath) {
console.log(filepath + ' was changed.');
})
this.on('added', function(filepath) {
console.log(filepath + ' was added.');
console.log(this.watched());
})
this.on('all', function(event, filepath) {
console.log(filepath + ' was ' + event);
});
this.on('error', function(err) {
console.log(err);
})
}) Works as currently intended where new files in old directories are detected. However, in this task, that is not the case. Somewhere from gaze to task the add event or all event is getting lost. Investigating further... |
So, maybe you can answer this and I'm missing something but at https://github.com/gruntjs/grunt-contrib-watch/blob/master/tasks/watch.js#L105, the code glob is expanded to match files, and then you create watchers on each file. Gaze is no longer watching a directory for new files, it's just watching those files to see them be changed and deleted. This line was changed in this commit.. c36fea1 I see that it was changed so that exclusions would be respected.. Maybe this is related to the issue that I ran into trying to create an exclusion for node_modules in gaze? Personally, I feel that Gaze should deal with the excluding, not the watch task. |
So, changing this to
and passing the globs directly to Gaze gets the added files working on Windows 7, however I'm getting some weird behaviour. Most likely because it doesn't do the exclusions right. I don't know enough about the libraries to know if this kind of thing is expected. But to explain what is being shown in the image. I changed that new.html file and you can see some console logs showing the four "glob arrays?" this should be watching. The change event is picked up on new.html, which causes a JST task to run, which recreates a new templates.js file. This fires off a change event for that, which for some reason fires added events on the vendor folder (this has existed the whole time). But most importantly, it fires off the backend_js tasks, for a change on templates.js which lives in the public folder, which is explicitly excluded. I'd say, there needs to be some work done on Gaze regarding minimatch exclusions. I'll try, but I can promise no pull request as this is outside my area of expertises :( I'm not sure how people are getting added events in this task right now, because as far as I can tell, it's impossible. My suggestion would be to get Gaze working nicely with exclusions then just pop the globs directly through. Here is my gruntfile in case it helps figure this out.. I removed one extraneous glob from backend_js. module.exports = function(grunt) {
'use strict';
//Project Configuration
grunt.initConfig({
watch: {
less: {
files: 'less/**/*.less',
tasks: ['less:development'],
options: {
interrupt : true
}
},
frontend_js: {
files: ['public/js/**/*.js', '!public/js/vendor/*.js', '!public/js/templates.js'],
tasks: ['exec:test_frontend'], //add requirejs task
options: {
interrupt: false
}
},
backend_js: {
files: ['**/*.js', '!public/**/*.js', '!node_modules/**/*.js'],
tasks: ['exec:test_backend'],
options: {
interrupt: false
}
},
templates: {
files: ['templates/**/*.html'],
tasks: ['jst:development'],
options: {
interrupt: true
}
}
},
exec: {
test_all: {
cmd: "mocha --colors test"
},
test_frontend: {
cmd: "mocha --colors --recursive test/frontend"
},
test_backend: {
cmd: "mocha --colors --recursive test/backend"
}
},
jst: {
development: {
options: {
amdWrapper: true,
prettify: true,
processContent: function(src) {
return src.replace(/(^\s+|\s+$)/gm, '');
}
},
files: {
"public/js/templates.js": ["templates/**/*.html"]
}
},
production: {
options: {
amdWrapper: true,
processContent: function(src) {
return src.replace(/(^\s+|\s+$)/gm, '');
}
},
files: {
"public/js/templates.js": ["templates/**/*.html"]
}
}
},
less: {
development: {
options: {
paths: "less/include"
},
files: [
{
expand: true,
//flatten: true, //will make dest folder flat
cwd: 'less/',
src: ['**/*.less', '!include/*.less'],
dest: 'public/css/',
ext: '.css'
}
]
},
production: {
}
}
});
grunt.loadNpmTasks('grunt-exec');
grunt.loadNpmTasks('grunt-contrib-jst');
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.registerTask('test', ['exec:test_all']);
grunt.registerTask('build_development', 'less:development');
} |
Some code inside gaze is way to greedy and trying to add every file from a folder that it is watching regardless of whether or not it matches an existing pattern :( (It's also of course possible I messed something up :P) The *** FINAL *** messages and the pattern are added to the Gaze.prototype.add method to aid debugging of adding the exclusions. I thought I was done, and getting ready to submit a pull request, when I went and saved my gruntfile, it worked, but Gaze went ahead and added all the files and folders that were in the same directory as the gruntfile.
|
@jamie-stackhouse thanks for all your work on this! Just a suggestion. How I usually tackle these things is to first create tests that show the exact behavior I'm working towards. Then work on the code until those tests pass. This issue is difficult for me because I believe I have passing tests that demonstrates the issue reported. Ideally I'd like to have a failing test case that reveals the issue reported so we can work towards a fix. I really appreciate your time on this and am looking forward to see what you come up with. Thanks! |
@shama, Gaze did have testcases that passed, because the actual functionality in Gaze for adding files was great 👍 The issue was that it wasn't a glob being passed into Gaze from this Task anymore, it was an already expanded set of files from the globs passed in, this changed I believe with the merge from #30, so Gaze never touched the initial glob. I hope I'm getting the terminology right :) After changing that, the behaviour was not ideal though, so I've kinda ported the Grunt expand method into Gaze and asyncimified it, and now trying to figure out why it's adding files that don't match the initial patterns, I'm assuming I've done something incorrect with the Gaze internals and forgot to register something somewhere :) |
I have the same problem: :( EDIT: This seems to work: https://github.com/gruntjs/grunt-contrib-watch/pull/43/files#r2843299 |
donaldpipowitch, if you do not need exclusion patterns that will be enough to pass the patterns through, if you want to exclude certain files, you are going to need to use the referenced pull request in Gaze. |
A fix is coming from upstream and will be here soon. |
@shama awesome! I took a look at the branch, looks much nicer than mine :P Thanks! |
Waiting for the fix 👍 |
Thank you @jamie-stackhouse for identifying the underlying problem! |
I didn't know whether you would want a new issue or for this one to be re-opened. As it's the same problem and the same test fails I'm hoping re-opening this one is correct. I'm seeing this issue with the following versions: This problem is also affecting Ubuntu 13.04 with the same versions of node, grunt, and grunt-contrib-watch. New files only, modified and deleted are working. |
Found this thread via Google. Having the same issue. OS X 10.8.4 I have a simple watch task:
And saving to any file in the cwd causes grunt watch to trigger. Even if I save the Gruntfile, which is in the root directory and not even listed in the watch: Running "watch" task
All of those files are already in the cwd, so why it's picking up that they've been added again is beyond me. |
Having the same issue on Mac OS 10.6.8 And btw the tests are not running. I'm not sure if i'm doing them right, but if i go to the grunt-contrib-watch folder and call |
@snrbrnjna Would you mind running the tests in verbose mode? |
I just ran the tests, hoping to solve this for me on osx 10.9, and the tests hang on Just to confirm, I'm here because I'm seeing this issue as well. New files aren't getting picked up by watch. edit: fresh reinstall of the package has it hanging on Watch 0.5.3 |
After reading a bit more about this issue, I tried upgrading to Node 0.10.22 and this behavior disappeared. All is working now. |
Grunt-contrib-watch isn't detecting files new file additions for me on osx. I assume this is related to issue #4 (the test provided in issue #4 confirms the problem). File changes and file deletions are handled correctly.
OSX: 10.8.2
node: 0.8.15
grunt: 0.3.17
grunt-contrib-watch: 0.1.4
The text was updated successfully, but these errors were encountered: