-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
Stabilize fs.cp()
, fs.cpSync()
, fsPromises.cp()
methods
#44598
Comments
@nodejs/fs |
👍 This is a useful API, but the documentation regarding recursive directory copies should be clarified. It currently states
But this is not quite right, as |
Possible to stabilize them before v20? #47381 |
Hi, just to report a strange behavior, I am not sure if it is intended or a bug. fsPromises.cp(
sourceFile,
destinationDir,
{"recursive": true}
); I get this error:
To fix, I have to use: fsPromises.cp(
sourceFile,
destinationDir + "/dstFileName.txt",
{"recursive": true}
); I was expecting a behavior basically as close as possible to the standard bash My node is v20.2.0. Regards |
There has been no activity on this feature request for 5 months and it is unlikely to be implemented. It will be closed 6 months after the last non-automated comment. For more information on how the project manages feature requests, please consult the feature request management document. |
Still relevant, as it's still not stable yet. |
There has been no activity on this feature request for 5 months. To help maintain relevant open issues, please add the
never-stale
|
Should be worth adding the never-stale label to this issue, as the issue is relevant until these fs methods are marked as stable. |
The error messages for `ERR_FS_CP_DIR_TO_NON_DIR` and `ERR_FS_CP_NON_DIR_TO_DIR` were the inverse of the copy direction actually performed. Refs: nodejs#44598 (comment)
The error messages for `ERR_FS_CP_DIR_TO_NON_DIR` and `ERR_FS_CP_NON_DIR_TO_DIR` were the inverse of the copy direction actually performed. Refs: nodejs#44598 (comment)
PR-URL: #53127 Fixes: #44598 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Mohammed Keyvanzadeh <[email protected]>
The error messages for `ERR_FS_CP_DIR_TO_NON_DIR` and `ERR_FS_CP_NON_DIR_TO_DIR` were the inverse of the copy direction actually performed. Refs: #44598 (comment) PR-URL: #53150 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: LiviaMedeiros <[email protected]> Reviewed-By: Feng Yu <[email protected]>
PR-URL: #53127 Fixes: #44598 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Mohammed Keyvanzadeh <[email protected]>
The error messages for `ERR_FS_CP_DIR_TO_NON_DIR` and `ERR_FS_CP_NON_DIR_TO_DIR` were the inverse of the copy direction actually performed. Refs: #44598 (comment) PR-URL: #53150 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: LiviaMedeiros <[email protected]> Reviewed-By: Feng Yu <[email protected]>
PR-URL: nodejs#53127 Fixes: nodejs#44598 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Mohammed Keyvanzadeh <[email protected]>
The error messages for `ERR_FS_CP_DIR_TO_NON_DIR` and `ERR_FS_CP_NON_DIR_TO_DIR` were the inverse of the copy direction actually performed. Refs: nodejs#44598 (comment) PR-URL: nodejs#53150 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: LiviaMedeiros <[email protected]> Reviewed-By: Feng Yu <[email protected]>
PR-URL: nodejs#53127 Fixes: nodejs#44598 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Mohammed Keyvanzadeh <[email protected]>
The error messages for `ERR_FS_CP_DIR_TO_NON_DIR` and `ERR_FS_CP_NON_DIR_TO_DIR` were the inverse of the copy direction actually performed. Refs: nodejs#44598 (comment) PR-URL: nodejs#53150 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: LiviaMedeiros <[email protected]> Reviewed-By: Feng Yu <[email protected]>
The error messages for `ERR_FS_CP_DIR_TO_NON_DIR` and `ERR_FS_CP_NON_DIR_TO_DIR` were the inverse of the copy direction actually performed. Refs: #44598 (comment) PR-URL: #53150 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: LiviaMedeiros <[email protected]> Reviewed-By: Feng Yu <[email protected]>
The error messages for `ERR_FS_CP_DIR_TO_NON_DIR` and `ERR_FS_CP_NON_DIR_TO_DIR` were the inverse of the copy direction actually performed. Refs: #44598 (comment) PR-URL: #53150 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: LiviaMedeiros <[email protected]> Reviewed-By: Feng Yu <[email protected]>
What is the problem this feature will solve?
Currently, these methods are marked as Experimental (Stability: 1):
fs.cp()
fs.cpSync()
fsPromises.cp()
There were no major changes since their introduction in Node.js v16.7.0, so it should be safe to mark them Stable (Stability: 2) as per the Stability index.
If somehow, these methods are still not ready to be stable, this is a tracking issue/roadmap to know what are the needed TODOs before marking them as stable.
What is the feature you are proposing to solve the problem?
Marking
fs.cp()
,fs.cpSync()
,fsPromises.cp()
methods as stable (Stability: 2).For automated test purposes, mocking
fs
module is a must.Currently, the most used userland library for that is probably mock-fs, and doesn't support these methods.
Before marking this API stable, Node.js should provide the needed feature(s) for mocking this API in userland, or even better, include
mock-fs
in Node.js core, this can be well suited with the newtest_runner
module.Related issues: tschaub/mock-fs#358, #37746.
What alternatives have you considered?
I think it's best to avoid using experimental APIs, avoid warnings, and simply use features subject to semantic-versioning for easier Node.js upgrades.
The current workaround, I personally use and end up copy/pasting in several projects (too small to be an
npm
package IMO):By marking this API as stable, I should be able to use it like this:
The text was updated successfully, but these errors were encountered: