Skip to content

Commit

Permalink
ref(fs) only validate options if they are passed
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasBa committed Jul 15, 2024
1 parent 6ba0af1 commit 78b1e27
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions lib/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);

Expand Down

0 comments on commit 78b1e27

Please sign in to comment.