I already have read the documentation of Node.js and, unless if I missed something, it does not tell what the parameters contain in certain operations, in particular fs.mkdi
The node.js docs for fs.mkdir
basically defer to the Linux man page for mkdir(2). That indicates that EEXIST
will also be indicated if the path exists but isn't a directory which creates an awkward corner case if you go this route.
You may be better off calling fs.stat which will tell you whether the path exists and if it's a directory in a single call. For (what I'm assuming is) the normal case where the directory already exists, it's only a single filesystem hit.
These fs
module methods are thin wrappers around the native C APIs so you've got to check the man pages referenced in the node.js docs for the details.