-
-
Notifications
You must be signed in to change notification settings - Fork 252
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
omit parameters #111
Comments
Options are not required, only the callback.
|
Why would the callback be required if I can just pass in an empty function? |
Because race conditions should be opt-in. If you have a rimraf (or file creation, stat, etc.) and don't provide a callback, then there is no way for your program to behave in a deterministic manner. It could take a long time to delete that file, or barely any time at all. If you want a simpler program, then the right way to go is to use If you really truly want to just fire it off into the ether, and never be alerted, that's fine, but this module (like most filesystem utilities in Node.js) requires that you explicitly state that intention by providing a function that does nothing. The purpose is to make it clear in your program that that's what you're doing, and that it's on purpose rather than an oversight. The order of the assertions is misleading, though, because it does seem to indicate that options are required rather than that a callback is required. I will reorder the assertions in the rimraf function to make the reason for the failure clearer. |
Ah, I should've looked at .sync more in depth, I agree with the decision that you must state your intention explicitly. My bad |
Clarify assertions: cb is required, options are not … Fix isaacs/rimraf#111 Credit: @isaacs
Clarify assertions: cb is required, options are not Fixes: isaacs/rimraf#111 Credit: @isaacs
Clarify assertions: cb is required, options are not Fixes: isaacs/rimraf#111 Credit: @isaacs
Sometimes you just want to delete a directory and don't care wether or not that happened,
currently I need to pass this:
As both the options and callback parameter are required. Wouldn't it be easier if you could just omit the parameters if you didn't need them?
It took me a couple minutes longer than it should've to figure this out, I eventually found out how to do this due to #96
The text was updated successfully, but these errors were encountered: