nodejs / tooling

Advancing Node.js as a framework for writing great tools
171 stars 15 forks source link

Recursive copy #98

Closed iansu closed 2 years ago

iansu commented 3 years ago

Implement a recursive copy command in Node.js. I have been drafting a proposal for this functionality in this document: https://hackmd.io/Q2O7hVyZSKClYW9Vyipeig

At this stage I'd like feedback from the Tooling group on the proposal. Once we're happy with it we can open an issue in the main Node.js repo to get broader feedback. If all goes well we can follow up with an implementation.

iansu commented 3 years ago

@RyanZim We're considering using the fs-extra recursive copy implementation in Node.js. I'd love your feedback on this proposal and on incorporating part of fs-extra into Node core. cc @CxRes

RyanZim commented 3 years ago

@manidlou is the collaborator that handles most things related to copy and move in fs-extra; so looping him in here since his feedback is probably most useful here.

Would you be planning on implementing the filter option as well?

CxRes commented 3 years ago

I am not involved with fs-extra though I use it in my work. And, I find the copy function incredibly useful.

However, from the point of view of nodejs, I think the copy function as implemented in fs-extra is limited. Don't get me wrong, it is really good for day to day use, its just that recursive copy is a relatively complex operation.

I would suggest that you consider cp, rsync and Windows Robocopy for inspiration.

A few things, I would like are:

Perhaps later you can add:

manidlou commented 3 years ago

@iansu I just want to remind you that our copy implementation in fs-extra is a bit different than unix cp command.

For instance, in fs-extra, when copying a file to a different directory, like copy('src-file.js', 'some/dir/dest-file.js') the user requires to explicitly specify the destination file name meaning copy('src-file.js', 'some/dir/') would fail in fs-extra while it works fine in the unix cp command.

That was a source of confusion for some of our users because they have this assumption that fs-extra functions would work like unix commands (which is a fair assumption since node is very unix-y) but we at fs-extra decided to go with explicitness.

So probably something that you might want to consider when deciding on the behavior of the function.