jprichardson / node-fs-extra

Node.js: extra methods for the fs object like copy(), remove(), mkdirs()
MIT License
9.43k stars 775 forks source link

Wrong documents about `copy` and `copySync` #1039

Closed hyf0 closed 5 months ago

hyf0 commented 5 months ago

I just look into the code.

https://github.com/jprichardson/node-fs-extra/blob/d96f2655f181f1c6b1641711619400140a89d027/lib/copy/copy.js#L129-L131

Now copy will copy directory recursively instead not doing it like the document said in

https://github.com/jprichardson/node-fs-extra/blob/d96f2655f181f1c6b1641711619400140a89d027/docs/copy-sync.md?plain=1#L5


The document of @types/fs-extea@11.0.4 is also wrong.

RyanZim commented 5 months ago

I think you're misunderstanding the docs. copy will recurse directories, the point is that it does not copy the top-level directory itself, so you can specify an existing directory with contents as a destination, and it will copy everything in the source directory to the destination without overwriting the existing destination contents (assuming there's no conflicting files).

hyf0 commented 5 months ago

Yeah. I got it wrong. Thanks for explaining.