Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fs.cp coming to Node.js core #912

Open
RyanZim opened this issue Jul 15, 2021 · 5 comments
Open

fs.cp coming to Node.js core #912

RyanZim opened this issue Jul 15, 2021 · 5 comments

Comments

@RyanZim
Copy link
Collaborator

RyanZim commented Jul 15, 2021

As per nodejs/node#39372; Node.js is considering moving copy*() to fs core. This will create a naming conflict between our method and fs core when it's released. How do we want to handle this?

@bcoe
Copy link

bcoe commented Jul 31, 2021

we've since moved to fs.cp.

@RyanZim
Copy link
Collaborator Author

RyanZim commented Jul 31, 2021

Closing as this won't be an issue with the current direction.

@RyanZim RyanZim closed this as completed Jul 31, 2021
@manidlou
Copy link
Collaborator

manidlou commented Aug 3, 2021

I figured I could reopen this instead of creating a new issue 😁

So another thing that we need to think about here at fs-extra is the options for copy method because considering latest changes on nodejs/node#39372 these are some differences between node core fs.cp() and fse.copy() options:

  • There is a recursive option in fs.cp() that is default to false. In fs-extra we copy the directory recursively by default.
  • The overwrite option is renamed to force in fs.cp().
  • Currently in fs-extra options param can be either an object or a function. In the case of a function, it will be passed as the filter function, but in node core fs.cp() the options param is always an object.

When nodejs/node#39372 gets landed in node core, we probably want to use it wherever is possible but as long as we support older node versions (without fs.cp()) we would fallback to our current (soon to be fallback) implementation (the same thing that we did for fs.copyFile()) and in that case we need to think about how we want to handle backwards compatibility when using fs.cp() and fse.copy() together.

@manidlou manidlou reopened this Aug 3, 2021
@manidlou manidlou changed the title Naming conflict with Node.js core Naming and options conflict with Node.js core fs.cp() method Aug 3, 2021
@manidlou manidlou changed the title Naming and options conflict with Node.js core fs.cp() method Options conflict with Node.js core fs.cp() method Aug 3, 2021
@manidlou manidlou changed the title Options conflict with Node.js core fs.cp() method Naming conflict with Node.js core Aug 3, 2021
@RyanZim
Copy link
Collaborator Author

RyanZim commented Aug 3, 2021

fse.copy should retain its current options and defaults; but use fs.cp under the hood where possible. When fs.cp is supported everywhere, we should probably consider deprecating fse.copy, in favor of people using fs.cp directly; they can use the new options/defaults when they migrate there.

@RyanZim RyanZim changed the title Naming conflict with Node.js core fs.cp coming to Node.js core Sep 21, 2021
@RyanZim RyanZim added this to the 11.0.0 milestone Oct 20, 2022
@RyanZim
Copy link
Collaborator Author

RyanZim commented Oct 20, 2022

fs.cp is still experimental, so holding off actually porting.

@RyanZim RyanZim removed this from the 11.0.0 milestone Oct 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants