GeezerVison is showing github.com — fs: remove unnecessary option argument validation · nodejs/node@8086337
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: lib/fs.js +9-8Lines changed: 9 additions & 8 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -1349,19 +1349,20 @@ function mkdirSync(path, options) { |
1349 | 1349 | let mode = 0o777; |
1350 | 1350 | let recursive = false; |
1351 | 1351 | if (typeof options === 'number' || typeof options === 'string') { |
1352 | | - mode = options; |
| 1352 | + mode = parseFileMode(options, 'mode'); |
1353 | 1353 | } else if (options) { |
1354 | | - if (options.recursive !== undefined) |
| 1354 | + if (options.recursive !== undefined) { |
1355 | 1355 | recursive = options.recursive; |
1356 | | - if (options.mode !== undefined) |
1357 | | - mode = options.mode; |
| 1356 | + validateBoolean(recursive, 'options.recursive'); |
| 1357 | + } |
| 1358 | + if (options.mode !== undefined) { |
| 1359 | + mode = parseFileMode(options.mode, 'options.mode'); |
| 1360 | + } |
1358 | 1361 | } |
1359 | | - path = getValidatedPath(path); |
1360 | | - validateBoolean(recursive, 'options.recursive'); |
1361 | 1362 |
|
1362 | 1363 | const result = binding.mkdir( |
1363 | | - path, |
1364 | | - parseFileMode(mode, 'mode'), |
| 1364 | + getValidatedPath(path), |
| 1365 | + mode, |
1365 | 1366 | recursive, |
1366 | 1367 | ); |
1367 | 1368 |
|
|