stdlib
stdlib copied to clipboard
feat: add `fs/mkdir`
If applied, this commit will add the package fs/mkdir
Description
What is the purpose of this pull request?
This pull request adds the package fs/mkdir for creating a directory asynchronously and synchronously.
Related Issues
Does this pull request have any related issues?
This pull request:
- resolves #2116
Questions
Any questions for reviewers of this pull request?
- When the
recursiveoption is set totrue, I have to handle some potential error, and I mainly borrowed the idea from mkdirp, but I am not sure if these error codes are enough here. - This package aligns with the
mkdirin node, so it will returnundefinedin some cases. But I noticed some similarstdlibpackages returnnull, so doesmkdiralso returnnullinstead ofundefined? - When generating examples and doctest, sometimes it triggers errors, but I am not sure the reasons.
Other
Any other information relevant to this pull request? This may include screenshots, references, and/or implementation notes.
No.
Checklist
Please ensure the following tasks are completed before submitting this pull request.
- [x] Read, understood, and followed the contributing guidelines.
@stdlib-js/reviewers
Hi, @kgryte @Planeshifter. I've implemented this package.
The main idea is, if mkdir is called without options argument or the recursive option is false, use the native mkdir. Otherwise, recursively create new directories. This way, I don't need to check the version of node.
Notes:
- I mainly consulted mkdirp about error handling and polyfill.
- This package aligns with the latest version of
mkdir(usage and return). It also explicitly handle error for sync version (return error object), just like otherfspackages instdlib. - This package uses
statandrmdirfromfs, which can be replaced with@stdlib/fs/statand@stdlib/fs/rmdirin the future. - It didn't pass two checks because the
fixturesdirectories are not pushed.
I am looking forward to your suggestions.
Thank you!
Test report.