node-fs-extra icon indicating copy to clipboard operation
node-fs-extra copied to clipboard

fs.cp coming to Node.js core

Open RyanZim opened this issue 2 years ago • 5 comments

As per https://github.com/nodejs/node/pull/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?

RyanZim avatar Jul 15 '21 19:07 RyanZim

we've since moved to fs.cp.

bcoe avatar Jul 31 '21 17:07 bcoe

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

RyanZim avatar Jul 31 '21 23:07 RyanZim

I figured I could reopen this instead of creating a new issue :grin:

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 avatar Aug 03 '21 04:08 manidlou

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 avatar Aug 03 '21 13:08 RyanZim

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

RyanZim avatar Oct 20 '22 19:10 RyanZim