| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
There was a problem hiding this comment.
Other modules write it as module.function() and point the user to what to use instead (e.g. 'http.createClient is deprecated. Use http.request instead.'). I would suggest following that.
Sorry, something went wrong.
|
It's probably a good idea to update most uses of fs.exists() in the test suit as well. The only exceptions I can think of are simple/test-fs-exists and maybe simple/test-fs-null-bytes. |
Sorry, something went wrong.
These methods don't follow standard conventions, and shouldn't be used anyway.
|
@bnoordhuis ready for review again. |
Sorry, something went wrong.
|
Actually, accessSync looks misconventional as well. Only way to use this method is to wrap your code with try / catch block and catch error if provided path is not accessible. The possibility to store existence in variable might be expectable. |
Sorry, something went wrong.
|
@cjihrig LGTM @vtambourine I kind of like it. I hope it discourages the anti-pattern of checking if a file exists before trying to open it. |
Sorry, something went wrong.
|
Can you please explain why this is considered as anti-pattern? Besides, consider following situation. I want to ensure that set of particular files exists (set of configs, for example, server.config.js, client.config.js etc.). One way of doing that is to store the existence of each file in hash, then filter out all existing files and initialise rests with some default content. Does this solution uses anti-pattern? |
Sorry, something went wrong.
Because the way most people use it, it's a TOCTOU race condition: the file may have changed or have been deleted between checking and opening it. If you are going to open it, then you need to be prepared for such eventualities, so you might as well skip the check and open it straight away. |
Sorry, something went wrong.
|
Ok, thank you. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
These methods don't follow standard conventions, and shouldn't be used anyway.
This closes #103