-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
//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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.