grunt
grunt copied to clipboard
Change the behavior of file.recurse so that it will log an error if it p...
...rocesses a broken symlink instead of causing a fatal error. We wrap the call to fs.statSync(filepath).isDirectory() in a try/catch block, then log on the error condition.
This changes relates to this issue I filled - https://github.com/gruntjs/grunt/issues/1165
Right now, this is what happens for each file:
- stat the file. if that fails, throw an ENOENT exception and burst into flames.
- is the file a directory? if so, recurse.
- otherwise, assume it's a file and pass it into the callback.
Should this be the desired behavior?
- stat the file. if that fails, skip the file. (verbose log that the file was skipped?)
- is the file a directory? if so, recurse.
- otherwise, assume it's a file and pass it into the callback.
Will this cause problems for anyone?
ping @iancreditkarma ^
Ah sorry. I was waiting for additional comment from others. The description @cowboy gave is almost correct. The only difference is that the file would not be skipped if it failed the stat. It would be passed to the callback and an error level log would be produced.
I was thinking about this more and this should probably function more or less like the bare invocation of the unix utility find. find will simply list the file (without warning).
It should probably be up to the callback to handle any issues that arise with the files passed during the directory recursion.
@iancreditkarma what benefit is there if the callback is called for a file that can't be statted? It seems like it should be skipped.
ping @iancreditkarma ^
@cowboy @vladikoff - That sounds pretty reasonable - skipping files that can't be statted. I'm out of town until tomorrow. I'll update the pull request as soon as I get back in town.
Ping @iancreditkarma any updates?