| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 2992d0b commit 937fa5d
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -37,6 +37,7 @@ const { | |||
| 37 | 37 | const { once } = require('internal/util'); | |
| 38 | 38 | const { toPathIfFileURL } = require('internal/url'); | |
| 39 | 39 | const { | |
| 40 | + validateBoolean, | ||
| 40 | 41 | validateInt32, | |
| 41 | 42 | validateUint32 | |
| 42 | 43 | } = require('internal/validators'); | |
@@ -674,15 +675,11 @@ const defaultRmdirOptions = { | |||
| 674 | 675 | const validateRmOptions = hideStackFrames((path, options, callback) => { | |
| 675 | 676 | try { | |
| 676 | 677 | options = validateRmdirOptions(options, defaultRmOptions); | |
| 678 | + validateBoolean(options.force, 'force'); | ||
| 677 | 679 | } catch (err) { | |
| 678 | 680 | return callback(err); | |
| 679 | 681 | } | |
| 680 | 682 | ||
| 681 | - if (typeof options.force !== 'boolean') | ||
| 682 | - return callback( | ||
| 683 | - new ERR_INVALID_ARG_TYPE('force', 'boolean', options.force) | ||
| 684 | - ); | ||
| 685 | - | ||
| 686 | 683 | lazyLoadFs().stat(path, (err, stats) => { | |
| 687 | 684 | if (err) { | |
| 688 | 685 | if (options.force && err.code === 'ENOENT') { | |
@@ -706,9 +703,7 @@ const validateRmOptions = hideStackFrames((path, options, callback) => { | |||
| 706 | 703 | ||
| 707 | 704 | const validateRmOptionsSync = hideStackFrames((path, options) => { | |
| 708 | 705 | options = validateRmdirOptions(options, defaultRmOptions); | |
| 709 | - | ||
| 710 | - if (typeof options.force !== 'boolean') | ||
| 711 | - throw new ERR_INVALID_ARG_TYPE('force', 'boolean', options.force); | ||
| 706 | + validateBoolean(options.force, 'force'); | ||
| 712 | 707 | ||
| 713 | 708 | try { | |
| 714 | 709 | const stats = lazyLoadFs().statSync(path); | |
@@ -742,9 +737,7 @@ const validateRmdirOptions = hideStackFrames( | |||
| 742 | 737 | ||
| 743 | 738 | options = { ...defaults, ...options }; | |
| 744 | 739 | ||
| 745 | - if (typeof options.recursive !== 'boolean') | ||
| 746 | - throw new ERR_INVALID_ARG_TYPE('recursive', 'boolean', options.recursive); | ||
| 747 | - | ||
| 740 | + validateBoolean(options.recursive, 'recursive'); | ||
| 748 | 741 | validateInt32(options.retryDelay, 'retryDelay', 0); | |
| 749 | 742 | validateUint32(options.maxRetries, 'maxRetries'); | |
| 750 | 743 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments