fs: add recursive cp method #39372
fs: add recursive cp method #39372
Conversation
This comment has been hidden.
This comment has been hidden.
|
lgtm |
|
Just making sure this doesn't land without documentation for the Promises and sync APIs |
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
|
Looks good overall! |
While we're rethinking options, should |
|
Also, for reference; discussion thread on how |
|
Further simplifications on the subject of replacing |
I was tempted to go with Thoughts? |
This comment has been hidden.
This comment has been hidden.
|
FYI, waiting on a windows machine at work (there are some hiccups with provisioning). Would happily pair with someone on fixing up the failing windows test, if anyone has a system up and running. |
|
Just want to make sure: does it behave like Unix Example, given:
Execute:
|
|
@targos there is not an attempt made to nest a directory under anther directory, as demonstrated in your Rather, Implementing this folder nesting logic would complicate the copy algorithm, and I'm not convinced it's behavior we need to carry over from |
|
@targos perhaps a compromise is to call out this difference in documentation, and pointing out that we don't support globs, and the when copying folders it's modeled after:
|
|
@bcoe @targos I'd also like to point your attention toward my comment here nodejs/tooling#98 (comment). I think it's worth mentioning it here again, our implementation of copy at So, I would say, if we keep it like this, it's a good idea to mention that in the docs to avoid confusion for users. |
This comment has been hidden.
This comment has been hidden.
|
LGTM. Let's make sure we follow up on the path-as-buffer issues, however. |
Introduces recursive cp method, based on fs-extra implementation.
This comment has been hidden.
This comment has been hidden.
| if (isPromise(shouldCopy)) { | ||
| throw new ERR_INVALID_RETURN_VALUE('boolean', 'filter', shouldCopy); |
aduh95
Aug 8, 2021
Contributor
Non blocking reflection, but probably something worth discussing before calling the API stable:
I'm not sure checking isPromise is the right thing to do here, %Array.prototype.filter% does not handle promises differently (JSON.stringify([0, 1].filter(async()=>false)) === '[0,1]'). Maybe we could emit a warning instead of throwing? That may help users spot if they have passed by mistake an async function, but wouldn't crash if they just happen to return a Promise object here.
Non blocking reflection, but probably something worth discussing before calling the API stable:
I'm not sure checking isPromise is the right thing to do here, %Array.prototype.filter% does not handle promises differently (JSON.stringify([0, 1].filter(async()=>false)) === '[0,1]'). Maybe we could emit a warning instead of throwing? That may help users spot if they have passed by mistake an async function, but wouldn't crash if they just happen to return a Promise object here.
targos
Aug 9, 2021
Member
The reason that Array.prototype.filter doesn't handle promises differently is mostly historical. I can't think of a correct use case where the user wants to return a Promise and expects it to be treated as a truthy value.
The reason that Array.prototype.filter doesn't handle promises differently is mostly historical. I can't think of a correct use case where the user wants to return a Promise and expects it to be treated as a truthy value.
|
lgtm |
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
Introduces recursive cp method, based on fs-extra implementation. PR-URL: #39372 Fixes: #35880 Refs: nodejs/tooling#98 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ian Sutherland <ian@iansutherland.ca>
|
Landed in 87d6fd7 |
Introduces recursive cp method, based on fs-extra implementation
Refs: nodejs/tooling#98
Fixes: #35880
Opening to start conversation.
TODO:
CC: @nodejs/tooling, @jprichardson, @manidlou, @RyanZim