-
Notifications
You must be signed in to change notification settings - Fork 30k
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: add recursive cp method #39372
fs: add recursive cp method #39372
Conversation
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just making sure this doesn't land without documentation for the Promises and sync APIs
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good overall! 🙌
While we're rethinking options, should |
Also, for reference; discussion thread on how |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Further simplifications on the subject of replacing open + futimes + close
with utimes
.
I was tempted to go with Thoughts? |
This comment has been minimized.
This comment has been minimized.
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. |
Introduces recursive cp method, based on fs-extra implementation.
This comment has been minimized.
This comment has been minimized.
if (isPromise(shouldCopy)) { | ||
throw new ERR_INVALID_RETURN_VALUE('boolean', 'filter', shouldCopy); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
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. 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>
Notable changes: * fs: * add recursive cp method (Benjamin Coe) #39372
Is there any place to give feedback on this function? Just looking through the docs, I think the option [EDIT] |
@lostpebble please feel free to open an issue. As much as possible I'd like to model after cp's flags, but perhaps clobber is the better name in this case? One good thing about |
As per nodejs/node#39372 (comment) Resolves #918
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