From ce7a3c296ae4b7fdb4ac52d0481e77664d07afb0 Mon Sep 17 00:00:00 2001 From: JonasBa Date: Mon, 15 Jul 2024 11:37:16 -0400 Subject: [PATCH] fs: remove unnecessary option argument validation --- lib/fs.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/fs.js b/lib/fs.js index fa1e65b022a9ad..f6c457dd1669b4 100644 --- a/lib/fs.js +++ b/lib/fs.js @@ -1351,19 +1351,20 @@ function mkdirSync(path, options) { let mode = 0o777; let recursive = false; 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(recursive, 'options.recursive'); + } + if (options.mode !== undefined) { + mode = parseFileMode(options.mode, 'options.mode'); + } } - path = getValidatedPath(path); - validateBoolean(recursive, 'options.recursive'); const result = binding.mkdir( - path, - parseFileMode(mode, 'mode'), + getValidatedPath(path), + mode, recursive, );