Trott / fs-tools

fs helper utilities (walk, copy, remove, mkdir -p)
http://trott.github.com/fs-tools/
MIT License
20 stars 4 forks source link

Replaced fs.mkdir() with fstools.mkdir() in private function copy_directory() #16

Closed perfusorius closed 12 years ago

perfusorius commented 12 years ago

Using NDoc to create HTML documentation I get an error. When it tries to copy the skeleton dir to my target dir, it calls fs.mkdir(dst), which does not test for existence of dst. At least under Windows this throws an error and the copy exits before it's begun. Your method fstools.mkdir on the other hand checks for existence und hence protects from this error. My computer is running Windows 7. I don't know if this problem actually exists in Linux / Mac but I think my solution should not break on any platform. { [Error: EEXIST, file already exists '...\doc'] errno: 47, code: 'EEXIST', path: '...\doc' }

puzrin commented 12 years ago

I guess, this is feature, not a bug. You can run ndoc by accident on directory, wich contains significant data in ./doc subfolder. In this case your data can be destroyed. So, output dir should not exist.

The proper way is to do shell shcript, wich remove ./doc folder, and then run ndoc. For example, in *nix: https://github.com/nodeca/fs-tools/blob/master/Makefile#L43

Probably there're 2 separate bugs: improper code in fs-tools + improper error detection in ndoc

perfusorius commented 12 years ago

Yes, I see your point. One should explicitly delete the docs folder before creating docs. Unfortunatley copy_file does also not check if it overwrites a file... Maybe there could be a --force option to force overwrite?

puzrin commented 12 years ago

fs-tools.copy must overwrite by design. It was a bug, if it could not do that. We are in progress of code review.