Closed suedama1756 closed 12 years ago
So, this doesn't thrown an exception for just **/*
, it throws exceptions whenever files are deleted while and expand
method is running, in general. Right?
Yes, it's actually for any file if the timing is right. I've also just noticed that the version in the devel branch actually already includes the fix (return false);
I'm going to close this, as 0.4.0 should be coming out soon-ish.
Many editors including WebStorm work with temporary hidden copies of files, those temporary files are renamed/moved to overwrite the source file on save.
This can cause file.js to throw an exception in the expandByType function when using file watches, as the file may get deleted between being expanded and the fs.stateSync method being called.
function expandByType(type) { var args = grunt.utils.toArray(arguments).slice(1); return file.expand.apply(file, args).filter(function(filepath) { // Just return the filepath if it's an internal directive. if (grunt.task.getDirectiveParts(filepath)) { return filepath; } try { return fs.statSync(filepath)[type](); } catch(e) { throw grunt.task.taskError(e.message, e); } }); }
It would appear that the fs.statSync function is just being used to filter based on isFile or isDirectory, clearly if fs.StatSync fails due to the path not existing then it is neither. Perhaps the catch block should just return false, or verify the paths existence?