Closed cedx closed 10 years ago
Looks like it's blowing up trying to calculate the exclusions -- indeed node_modules is in the default exclude list: https://github.com/jakejs/jake/blob/master/lib/watch_task.js#L45 This is a pretty bad bug.
I'm not sure why it would still not work if you actually have the exclusion directories it wants. I seem to remember there being issues with watch on Windows, but that was some time back. I would have thought it would be working reliably by now.
You're absolutely right -- we shouldn't require people to ignore the Jakefile explicitly, even if it has a .js extension (but of course shouldn't require its presence either -- this is a bug).
I've opened a ticket for this bug: https://github.com/jakejs/jake/issues/263 Thanks for catching this!
I think you can close this issue : as you said, ENOENT, no such file or directory
is clearly related to the default exclusion list of watch task.
For the second part (task not working even with a node_modules
directory), I think this is related to the implementation of fs.watch/watchFile
on (this fucking) Windows.
If I try with a custom code, instead of Jake's watch task, the result is the same : no event is triggered when a change occurs :(
I'm trying to see how Isaacs succeeded to catch file events in its node-supervisor module (which works on Windows !).
Let me know what you find out.
Very disappointing... I saw nothing special in the code of node-supervisor, which uses fs.watchFile
.
So, I made some tests : I tried to watch a "cli.js" file in a "bin" directory, using the following Jakefile
.
The results are shown in the comments:
'use strict';
var fs=require('fs');
namespace('fsWatch', function() {
desc('File with fs.watch()');
task('file', function() {
fs.watch('bin/cli.js', function() {
jake.logger.log('fs.watch(file) => callback called');
// RESULT: Callback called 2 times on each 'change' event.
});
});
desc('Directory with fs.watch()');
task('dir', function() {
fs.watch('bin', function() {
jake.logger.log('fs.watch(dir) => callback called');
// RESULT: Callback called 2 times on each 'change' event.
});
});
});
namespace('fsWatchFile', function() {
desc('File with fs.watchFile()');
task('file', function() {
fs.watchFile('bin/cli.js', { interval: 1000 }, function() {
jake.logger.log('fs.watchFile(file) => callback called');
// RESULT: Callback called one time on each 'change' event.
});
});
desc('Directory with fs.watchFile()');
task('dir', function() {
fs.watchFile('bin', { interval: 1000 }, function() {
jake.logger.log('fs.watchFile(dir) => callback called');
// RESULT: Callback never called.
});
});
});
desc('Task used as prerequisite for jake.watchTask');
task('log', function() {
jake.logger.log('jake.watchTask => prerequesite called');
});
watchTask([ 'log' ], function() {
this.watchFiles.include([ 'bin/cli.js' ]);
// RESULT: Prerequesite never called.
});
Only the call to fs.watchFile('bin/cli.js')
gave the expected results. Can someone can confirm that on a Windows OS? Am I doing something wrong?
I gave up: I finally implemented a custom task using nodemon as a required module.
I close this issue as 2 things were involved:
Thanks so much for following up on this. Node generally does a good job of being cross-platform, but it still falls down pretty hard in some areas. #263 is fixed in 9239f6c0525be64c8dce09a28fc9b44236488266
I'm unable to make
jake watch
task working at all (not even a single time! Do I need to change my brain?).My config: Node.js 0.10.29 and Jake 0.7.17 on Windows 8.1.
I think there are several issues involved, so let's start with the most obvious problem :
jake watch
does not seem to work with global-only modules.Here is my Jakefile:
When I launch
jake watch
and change a file, an error occurs:There is no
node_modules
folder: my project only uses a few global modules (e.g. modules installed withnpm install -g <module>
). Why Jake is looking fornode_modules
folder even if it doesn't exist?If I create this folder, or if I use local modules, this task still doesn't work. But I'm still investigating... Does anyone has succeed in using watch tasks on Windows 8.1?
Off topic: I think watch task should explicitly ignore the
Jakefile
. It's quite common to name itJakefile.js
orJakefile.coffee
, but it's insane to trigger the watch cycle everytime we modify theJakefile
or to ignore it explictly.