doc: clarify mkdir() recursive behavior#48109
Conversation
|
I had to add some more practical explanation to a few lines and also noticed a piece of code wasn't working the way it was described as ,noticed code only worked with a relative path and also commented the code after adding a relative path. |
doc/api/fs.md
Outdated
| //Note the relative path to `tmp` below ,otherwise path won't be created in our project. | ||
|
|
||
| mkdir('./tmp/a/apple', { recursive: true }, (err) => { |
There was a problem hiding this comment.
| //Note the relative path to `tmp` below ,otherwise path won't be created in our project. | |
| mkdir('./tmp/a/apple', { recursive: true }, (err) => { | |
| // Create ./tmp/a/apple, regardless of whether ./tmp and ./tmp/a exist. | |
| mkdir('./tmp/a/apple', { recursive: true }, (err) => { |
There was a problem hiding this comment.
(The code should work fine with an absolute path instead of a relative path, but there are security implications to creating directories in /tmp with predictable names that aren't accounted for in the example code. It shouldn't ignore if someone else has already created the directory with permissions different than expected or with pre-existing contents. So I think it's good to switch it to a relative directory like you've done here or else some other absolute directory.)
There was a problem hiding this comment.
I think I have a better explanation to the whole behaviour of the code above ,can I go ahead and fix it?
Co-authored-by: Rich Trott <rtrott@gmail.com>
Co-authored-by: Rich Trott <rtrott@gmail.com>
|
Landed in 6599cfe |
PR-URL: #48109 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
PR-URL: #48109 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
PR-URL: nodejs#48109 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
PR-URL: nodejs#48109 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
PR-URL: nodejs#48109 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
No description provided.