node-fs-extra
node-fs-extra copied to clipboard
fs.cp coming to Node.js core
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?
we've since moved to fs.cp.
Closing as this won't be an issue with the current direction.
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
recursiveoption infs.cp()that is default tofalse. Infs-extrawe copy the directory recursively by default. - The
overwriteoption is renamed toforceinfs.cp(). - Currently in
fs-extraoptions 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 corefs.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.
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.
fs.cp is still experimental, so holding off actually porting.