grunt icon indicating copy to clipboard operation
grunt copied to clipboard

Change the behavior of file.recurse so that it will log an error if it p...

Open ian-plunkett-ck opened this issue 11 years ago • 7 comments

...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

ian-plunkett-ck avatar Jun 20 '14 00:06 ian-plunkett-ck

Right now, this is what happens for each file:

  1. stat the file. if that fails, throw an ENOENT exception and burst into flames.
  2. is the file a directory? if so, recurse.
  3. otherwise, assume it's a file and pass it into the callback.

Should this be the desired behavior?

  1. stat the file. if that fails, skip the file. (verbose log that the file was skipped?)
  2. is the file a directory? if so, recurse.
  3. otherwise, assume it's a file and pass it into the callback.

Will this cause problems for anyone?

cowboy avatar Jun 20 '14 17:06 cowboy

ping @iancreditkarma ^

vladikoff avatar Jun 24 '14 18:06 vladikoff

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.

ian-plunkett-ck avatar Jun 24 '14 18:06 ian-plunkett-ck

@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.

cowboy avatar Jul 10 '14 15:07 cowboy

ping @iancreditkarma ^

vladikoff avatar Jul 14 '14 20:07 vladikoff

@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.

ian-plunkett-ck avatar Jul 15 '14 19:07 ian-plunkett-ck

Ping @iancreditkarma any updates?

cowboy avatar Sep 19 '14 14:09 cowboy