AvianFlu / ncp

Asynchronous recursive file copying with Node.js.
MIT License
681 stars 103 forks source link

Fixed bugs relate to prevent copying to itself. #61

Closed iwege closed 9 years ago

iwege commented 10 years ago

I try to fix the issue #60, If I missed something , please let me know.

This PR refactoring the startsWith function and try to handle more situations. I add more testcases to test the different situations. * Some testcases can't used in Windows* :

  1. Copy to sub-folder
    1. src to src/out
  2. Copy to itself
    1. src to src
  3. Copy to the folder starts with src
    1. src to src_out
  4. Copy to the symlink folder
    1. src to src-symlink
  5. Copy the file to itself
    1. src/a to src/a
  6. More complex situations:
    1. src to src/src_out
    2. src to src_out/src

And I add mkdirp to devDependencies to create the directory easily.