diff --git a/lib/fs.js b/lib/fs.js index 2119554c0e72c1..639462ec83857e 100644 --- a/lib/fs.js +++ b/lib/fs.js @@ -1310,23 +1310,23 @@ function mkdir(path, options, callback) { if (typeof options === 'function') { callback = options; } else if (typeof options === 'number' || typeof options === 'string') { - mode = options; + mode = parseFileMode(options, 'mode'); } else if (options) { - if (options.recursive !== undefined) + if (options.recursive !== undefined){ recursive = options.recursive; - if (options.mode !== undefined) - mode = options.mode; + validateBoolean(options.recursive); + } + if (options.mode !== undefined){ + mode = parseFileMode(options.mode, 'options.mode') + } } callback = makeCallback(callback); - path = getValidatedPath(path); - - validateBoolean(recursive, 'options.recursive'); const req = new FSReqCallback(); req.oncomplete = callback; binding.mkdir( - path, - parseFileMode(mode, 'mode'), + getValidatedPath(path), + mode, recursive, req, );