| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent b04c4a4 commit eec0302
13 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3057,6 +3057,9 @@ The [`crypto.Certificate()` constructor][] is deprecated. Use | |||
| 3057 | 3057 | ||
| 3058 | 3058 | <!-- YAML | |
| 3059 | 3059 | changes: | |
| 3060 | + - version: REPLACEME | ||
| 3061 | + pr-url: https://github.com/nodejs/node/pull/58616 | ||
| 3062 | + description: End-of-Life. | ||
| 3060 | 3063 | - version: v16.0.0 | |
| 3061 | 3064 | pr-url: https://github.com/nodejs/node/pull/37302 | |
| 3062 | 3065 | description: Runtime deprecation. | |
@@ -3068,10 +3071,10 @@ changes: | |||
| 3068 | 3071 | description: Documentation-only deprecation. | |
| 3069 | 3072 | --> | |
| 3070 | 3073 | ||
| 3071 | - Type: Runtime | ||
| 3074 | + Type: End-of-Life | ||
| 3072 | 3075 | ||
| 3073 | - In future versions of Node.js, `recursive` option will be ignored for | ||
| 3074 | - `fs.rmdir`, `fs.rmdirSync`, and `fs.promises.rmdir`. | ||
| 3076 | + The `fs.rmdir`, `fs.rmdirSync`, and `fs.promises.rmdir` methods used | ||
| 3077 | + to support a `recursive` option. That option has been removed. | ||
| 3075 | 3078 | ||
| 3076 | 3079 | Use `fs.rm(path, { recursive: true, force: true })`, | |
| 3077 | 3080 | `fs.rmSync(path, { recursive: true, force: true })` or | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1589,6 +1589,9 @@ Renames `oldPath` to `newPath`. | |||
| 1589 | 1589 | <!-- YAML | |
| 1590 | 1590 | added: v10.0.0 | |
| 1591 | 1591 | changes: | |
| 1592 | + - version: REPLACEME | ||
| 1593 | + pr-url: https://github.com/nodejs/node/pull/58616 | ||
| 1594 | + description: Remove `recursive` option. | ||
| 1592 | 1595 | - version: v16.0.0 | |
| 1593 | 1596 | pr-url: https://github.com/nodejs/node/pull/37216 | |
| 1594 | 1597 | description: "Using `fsPromises.rmdir(path, { recursive: true })` on a `path` | |
@@ -1622,18 +1625,10 @@ changes: | |||
| 1622 | 1625 | --> | |
| 1623 | 1626 | ||
| 1624 | 1627 | * `path` {string|Buffer|URL} | |
| 1625 | - * `options` {Object} | ||
| 1626 | - * `maxRetries` {integer} If an `EBUSY`, `EMFILE`, `ENFILE`, `ENOTEMPTY`, or | ||
| 1627 | - `EPERM` error is encountered, Node.js retries the operation with a linear | ||
| 1628 | - backoff wait of `retryDelay` milliseconds longer on each try. This option | ||
| 1629 | - represents the number of retries. This option is ignored if the `recursive` | ||
| 1630 | - option is not `true`. **Default:** `0`. | ||
| 1631 | - * `recursive` {boolean} If `true`, perform a recursive directory removal. In | ||
| 1632 | - recursive mode, operations are retried on failure. **Default:** `false`. | ||
| 1633 | - **Deprecated.** | ||
| 1634 | - * `retryDelay` {integer} The amount of time in milliseconds to wait between | ||
| 1635 | - retries. This option is ignored if the `recursive` option is not `true`. | ||
| 1636 | - **Default:** `100`. | ||
| 1628 | + * `options` {Object} There are currently no options exposed. There used to | ||
| 1629 | + be options for `recursive`, `maxBusyTries`, and `emfileWait` but they were | ||
| 1630 | + deprecated and removed. The `options` argument is still accepted for | ||
| 1631 | + backwards compatibility but it is not used. | ||
| 1637 | 1632 | * Returns: {Promise} Fulfills with `undefined` upon success. | |
| 1638 | 1633 | ||
| 1639 | 1634 | Removes the directory identified by `path`. | |
@@ -4255,6 +4250,9 @@ rename('oldFile.txt', 'newFile.txt', (err) => { | |||
| 4255 | 4250 | <!-- YAML | |
| 4256 | 4251 | added: v0.0.2 | |
| 4257 | 4252 | changes: | |
| 4253 | + - version: REPLACEME | ||
| 4254 | + pr-url: https://github.com/nodejs/node/pull/58616 | ||
| 4255 | + description: Remove `recursive` option. | ||
| 4258 | 4256 | - version: v18.0.0 | |
| 4259 | 4257 | pr-url: https://github.com/nodejs/node/pull/41678 | |
| 4260 | 4258 | description: Passing an invalid callback to the `callback` argument | |
@@ -4305,18 +4303,10 @@ changes: | |||
| 4305 | 4303 | --> | |
| 4306 | 4304 | ||
| 4307 | 4305 | * `path` {string|Buffer|URL} | |
| 4308 | - * `options` {Object} | ||
| 4309 | - * `maxRetries` {integer} If an `EBUSY`, `EMFILE`, `ENFILE`, `ENOTEMPTY`, or | ||
| 4310 | - `EPERM` error is encountered, Node.js retries the operation with a linear | ||
| 4311 | - backoff wait of `retryDelay` milliseconds longer on each try. This option | ||
| 4312 | - represents the number of retries. This option is ignored if the `recursive` | ||
| 4313 | - option is not `true`. **Default:** `0`. | ||
| 4314 | - * `recursive` {boolean} If `true`, perform a recursive directory removal. In | ||
| 4315 | - recursive mode, operations are retried on failure. **Default:** `false`. | ||
| 4316 | - **Deprecated.** | ||
| 4317 | - * `retryDelay` {integer} The amount of time in milliseconds to wait between | ||
| 4318 | - retries. This option is ignored if the `recursive` option is not `true`. | ||
| 4319 | - **Default:** `100`. | ||
| 4306 | + * `options` {Object} There are currently no options exposed. There used to | ||
| 4307 | + be options for `recursive`, `maxBusyTries`, and `emfileWait` but they were | ||
| 4308 | + deprecated and removed. The `options` argument is still accepted for | ||
| 4309 | + backwards compatibility but it is not used. | ||
| 4320 | 4310 | * `callback` {Function} | |
| 4321 | 4311 | * `err` {Error} | |
| 4322 | 4312 | ||
@@ -6234,6 +6224,9 @@ See the POSIX rename(2) documentation for more details. | |||
| 6234 | 6224 | <!-- YAML | |
| 6235 | 6225 | added: v0.1.21 | |
| 6236 | 6226 | changes: | |
| 6227 | + - version: REPLACEME | ||
| 6228 | + pr-url: https://github.com/nodejs/node/pull/58616 | ||
| 6229 | + description: Remove `recursive` option. | ||
| 6237 | 6230 | - version: v16.0.0 | |
| 6238 | 6231 | pr-url: https://github.com/nodejs/node/pull/37216 | |
| 6239 | 6232 | description: "Using `fs.rmdirSync(path, { recursive: true })` on a `path` | |
@@ -6271,18 +6264,10 @@ changes: | |||
| 6271 | 6264 | --> | |
| 6272 | 6265 | ||
| 6273 | 6266 | * `path` {string|Buffer|URL} | |
| 6274 | - * `options` {Object} | ||
| 6275 | - * `maxRetries` {integer} If an `EBUSY`, `EMFILE`, `ENFILE`, `ENOTEMPTY`, or | ||
| 6276 | - `EPERM` error is encountered, Node.js retries the operation with a linear | ||
| 6277 | - backoff wait of `retryDelay` milliseconds longer on each try. This option | ||
| 6278 | - represents the number of retries. This option is ignored if the `recursive` | ||
| 6279 | - option is not `true`. **Default:** `0`. | ||
| 6280 | - * `recursive` {boolean} If `true`, perform a recursive directory removal. In | ||
| 6281 | - recursive mode, operations are retried on failure. **Default:** `false`. | ||
| 6282 | - **Deprecated.** | ||
| 6283 | - * `retryDelay` {integer} The amount of time in milliseconds to wait between | ||
| 6284 | - retries. This option is ignored if the `recursive` option is not `true`. | ||
| 6285 | - **Default:** `100`. | ||
| 6267 | + * `options` {Object} There are currently no options exposed. There used to | ||
| 6268 | + be options for `recursive`, `maxBusyTries`, and `emfileWait` but they were | ||
| 6269 | + deprecated and removed. The `options` argument is still accepted for | ||
| 6270 | + backwards compatibility but it is not used. | ||
| 6286 | 6271 | ||
| 6287 | 6272 | Synchronous rmdir(2). Returns `undefined`. | |
| 6288 | 6273 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -102,7 +102,6 @@ const { | |||
| 102 | 102 | }, | |
| 103 | 103 | copyObject, | |
| 104 | 104 | Dirent, | |
| 105 | - emitRecursiveRmdirWarning, | ||
| 106 | 105 | getDirent, | |
| 107 | 106 | getDirents, | |
| 108 | 107 | getOptions, | |
@@ -1109,11 +1108,7 @@ function lazyLoadRimraf() { | |||
| 1109 | 1108 | /** | |
| 1110 | 1109 | * Asynchronously removes a directory. | |
| 1111 | 1110 | * @param {string | Buffer | URL} path | |
| 1112 | - * @param {{ | ||
| 1113 | - * maxRetries?: number; | ||
| 1114 | - * recursive?: boolean; | ||
| 1115 | - * retryDelay?: number; | ||
| 1116 | - * }} [options] | ||
| 1111 | + * @param {{}} [options] | ||
| 1117 | 1112 | * @param {(err?: Error) => any} callback | |
| 1118 | 1113 | * @returns {void} | |
| 1119 | 1114 | */ | |
@@ -1123,60 +1118,45 @@ function rmdir(path, options, callback) { | |||
| 1123 | 1118 | options = undefined; | |
| 1124 | 1119 | } | |
| 1125 | 1120 | ||
| 1121 | + if (options?.recursive !== undefined) { | ||
| 1122 | + // This API previously accepted a `recursive` option that was deprecated | ||
| 1123 | + // and removed. However, in order to make the change more visible, we | ||
| 1124 | + // opted to throw an error if recursive is specified rather than removing it | ||
| 1125 | + // entirely. | ||
| 1126 | + throw new ERR_INVALID_ARG_VALUE( | ||
| 1127 | + 'options.recursive', | ||
| 1128 | + options.recursive, | ||
| 1129 | + 'is no longer supported', | ||
| 1130 | + ); | ||
| 1131 | + } | ||
| 1132 | + | ||
| 1126 | 1133 | callback = makeCallback(callback); | |
| 1127 | 1134 | path = getValidatedPath(path); | |
| 1128 | 1135 | ||
| 1129 | - if (options?.recursive) { | ||
| 1130 | - emitRecursiveRmdirWarning(); | ||
| 1131 | - validateRmOptions( | ||
| 1132 | - path, | ||
| 1133 | - { ...options, force: false }, | ||
| 1134 | - true, | ||
| 1135 | - (err, options) => { | ||
| 1136 | - if (err === false) { | ||
| 1137 | - const req = new FSReqCallback(); | ||
| 1138 | - req.oncomplete = callback; | ||
| 1139 | - binding.rmdir(path, req); | ||
| 1140 | - return; | ||
| 1141 | - } | ||
| 1142 | - if (err) { | ||
| 1143 | - return callback(err); | ||
| 1144 | - } | ||
| 1145 | - | ||
| 1146 | - lazyLoadRimraf(); | ||
| 1147 | - rimraf(path, options, callback); | ||
| 1148 | - }); | ||
| 1149 | - } else { | ||
| 1150 | - validateRmdirOptions(options); | ||
| 1151 | - const req = new FSReqCallback(); | ||
| 1152 | - req.oncomplete = callback; | ||
| 1153 | - binding.rmdir(path, req); | ||
| 1154 | - } | ||
| 1136 | + validateRmdirOptions(options); | ||
| 1137 | + const req = new FSReqCallback(); | ||
| 1138 | + req.oncomplete = callback; | ||
| 1139 | + binding.rmdir(path, req); | ||
| 1155 | 1140 | } | |
| 1156 | 1141 | ||
| 1157 | 1142 | /** | |
| 1158 | 1143 | * Synchronously removes a directory. | |
| 1159 | 1144 | * @param {string | Buffer | URL} path | |
| 1160 | - * @param {{ | ||
| 1161 | - * maxRetries?: number; | ||
| 1162 | - * recursive?: boolean; | ||
| 1163 | - * retryDelay?: number; | ||
| 1164 | - * }} [options] | ||
| 1145 | + * @param {{}} [options] | ||
| 1165 | 1146 | * @returns {void} | |
| 1166 | 1147 | */ | |
| 1167 | 1148 | function rmdirSync(path, options) { | |
| 1168 | 1149 | path = getValidatedPath(path); | |
| 1169 | 1150 | ||
| 1170 | - if (options?.recursive) { | ||
| 1171 | - emitRecursiveRmdirWarning(); | ||
| 1172 | - options = validateRmOptionsSync(path, { ...options, force: false }, true); | ||
| 1173 | - if (options !== false) { | ||
| 1174 | - return binding.rmSync(path, options.maxRetries, options.recursive, options.retryDelay); | ||
| 1175 | - } | ||
| 1176 | - } else { | ||
| 1177 | - validateRmdirOptions(options); | ||
| 1151 | + if (options?.recursive !== undefined) { | ||
| 1152 | + throw new ERR_INVALID_ARG_VALUE( | ||
| 1153 | + 'options.recursive', | ||
| 1154 | + options.recursive, | ||
| 1155 | + 'is no longer supported', | ||
| 1156 | + ); | ||
| 1178 | 1157 | } | |
| 1179 | 1158 | ||
| 1159 | + validateRmdirOptions(options); | ||
| 1180 | 1160 | binding.rmdir(path); | |
| 1181 | 1161 | } | |
| 1182 | 1162 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -56,7 +56,6 @@ const { | |||
| 56 | 56 | kWriteFileMaxChunkSize, | |
| 57 | 57 | }, | |
| 58 | 58 | copyObject, | |
| 59 | - emitRecursiveRmdirWarning, | ||
| 60 | 59 | getDirents, | |
| 61 | 60 | getOptions, | |
| 62 | 61 | getStatFsFromBinding, | |
@@ -812,16 +811,17 @@ async function rm(path, options) { | |||
| 812 | 811 | ||
| 813 | 812 | async function rmdir(path, options) { | |
| 814 | 813 | path = getValidatedPath(path); | |
| 815 | - options = validateRmdirOptions(options); | ||
| 816 | 814 | ||
| 817 | - if (options.recursive) { | ||
| 818 | - emitRecursiveRmdirWarning(); | ||
| 819 | - const stats = await stat(path); | ||
| 820 | - if (stats.isDirectory()) { | ||
| 821 | - return lazyRimRaf()(path, options); | ||
| 822 | - } | ||
| 815 | + if (options?.recursive !== undefined) { | ||
| 816 | + throw new ERR_INVALID_ARG_VALUE( | ||
| 817 | + 'options.recursive', | ||
| 818 | + options.recursive, | ||
| 819 | + 'is no longer supported', | ||
| 820 | + ); | ||
| 823 | 821 | } | |
| 824 | 822 | ||
| 823 | + options = validateRmdirOptions(options); | ||
| 824 | + | ||
| 825 | 825 | return await PromisePrototypeThen( | |
| 826 | 826 | binding.rmdir(path, kUsePromises), | |
| 827 | 827 | undefined, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -778,12 +778,6 @@ const defaultRmOptions = { | |||
| 778 | 778 | maxRetries: 0, | |
| 779 | 779 | }; | |
| 780 | 780 | ||
| 781 | - const defaultRmdirOptions = { | ||
| 782 | - retryDelay: 100, | ||
| 783 | - maxRetries: 0, | ||
| 784 | - recursive: false, | ||
| 785 | - }; | ||
| 786 | - | ||
| 787 | 781 | const validateCpOptions = hideStackFrames((options) => { | |
| 788 | 782 | if (options === undefined) | |
| 789 | 783 | return { ...defaultCpOptions }; | |
@@ -807,7 +801,10 @@ const validateCpOptions = hideStackFrames((options) => { | |||
| 807 | 801 | ||
| 808 | 802 | const validateRmOptions = hideStackFrames((path, options, expectDir, cb) => { | |
| 809 | 803 | options = validateRmdirOptions(options, defaultRmOptions); | |
| 810 | - validateBoolean(options.force, 'options.force'); | ||
| 804 | + validateBoolean.withoutStackTrace(options.force, 'options.force'); | ||
| 805 | + validateBoolean.withoutStackTrace(options.recursive, 'options.recursive'); | ||
| 806 | + validateInt32.withoutStackTrace(options.retryDelay, 'options.retryDelay', 0); | ||
| 807 | + validateUint32.withoutStackTrace(options.maxRetries, 'options.maxRetries'); | ||
| 811 | 808 | ||
| 812 | 809 | lazyLoadFs().lstat(path, (err, stats) => { | |
| 813 | 810 | if (err) { | |
@@ -839,6 +836,10 @@ const validateRmOptions = hideStackFrames((path, options, expectDir, cb) => { | |||
| 839 | 836 | const validateRmOptionsSync = hideStackFrames((path, options, expectDir) => { | |
| 840 | 837 | options = validateRmdirOptions.withoutStackTrace(options, defaultRmOptions); | |
| 841 | 838 | validateBoolean.withoutStackTrace(options.force, 'options.force'); | |
| 839 | + validateBoolean.withoutStackTrace(options.recursive, 'options.recursive'); | ||
| 840 | + validateInt32.withoutStackTrace(options.retryDelay, 'options.retryDelay', 0); | ||
| 841 | + validateUint32.withoutStackTrace(options.maxRetries, 'options.maxRetries'); | ||
| 842 | + | ||
| 842 | 843 | ||
| 843 | 844 | if (!options.force || expectDir || !options.recursive) { | |
| 844 | 845 | const isDirectory = lazyLoadFs() | |
@@ -862,35 +863,14 @@ const validateRmOptionsSync = hideStackFrames((path, options, expectDir) => { | |||
| 862 | 863 | return options; | |
| 863 | 864 | }); | |
| 864 | 865 | ||
| 865 | - let recursiveRmdirWarned; | ||
| 866 | - function emitRecursiveRmdirWarning() { | ||
| 867 | - if (recursiveRmdirWarned === undefined) { | ||
| 868 | - // TODO(joyeecheung): use getOptionValue('--no-deprecation') instead. | ||
| 869 | - recursiveRmdirWarned = process.noDeprecation; | ||
| 870 | - } | ||
| 871 | - if (!recursiveRmdirWarned) { | ||
| 872 | - process.emitWarning( | ||
| 873 | - 'In future versions of Node.js, fs.rmdir(path, { recursive: true }) ' + | ||
| 874 | - 'will be removed. Use fs.rm(path, { recursive: true }) instead', | ||
| 875 | - 'DeprecationWarning', | ||
| 876 | - 'DEP0147', | ||
| 877 | - ); | ||
| 878 | - recursiveRmdirWarned = true; | ||
| 879 | - } | ||
| 880 | - } | ||
| 881 | - | ||
| 882 | 866 | const validateRmdirOptions = hideStackFrames( | |
| 883 | - (options, defaults = defaultRmdirOptions) => { | ||
| 867 | + (options, defaults = { __proto__: null }) => { | ||
| 884 | 868 | if (options === undefined) | |
| 885 | 869 | return defaults; | |
| 886 | 870 | validateObject.withoutStackTrace(options, 'options'); | |
| 887 | 871 | ||
| 888 | 872 | options = { ...defaults, ...options }; | |
| 889 | 873 | ||
| 890 | - validateBoolean.withoutStackTrace(options.recursive, 'options.recursive'); | ||
| 891 | - validateInt32.withoutStackTrace(options.retryDelay, 'options.retryDelay', 0); | ||
| 892 | - validateUint32.withoutStackTrace(options.maxRetries, 'options.maxRetries'); | ||
| 893 | - | ||
| 894 | 874 | return options; | |
| 895 | 875 | }); | |
| 896 | 876 | ||
@@ -950,7 +930,6 @@ module.exports = { | |||
| 950 | 930 | copyObject, | |
| 951 | 931 | Dirent, | |
| 952 | 932 | DirentFromStats, | |
| 953 | - emitRecursiveRmdirWarning, | ||
| 954 | 933 | getDirent, | |
| 955 | 934 | getDirents, | |
| 956 | 935 | getOptions, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,31 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + | ||
| 3 | + const common = require('../common'); | ||
| 4 | + const assert = require('assert'); | ||
| 5 | + const { | ||
| 6 | + rmdir, | ||
| 7 | + rmdirSync, | ||
| 8 | + promises: { rmdir: rmdirPromise } | ||
| 9 | + } = require('fs'); | ||
| 10 | + | ||
| 11 | + assert.throws(() => { | ||
| 12 | + rmdir('nonexistent', { | ||
| 13 | + recursive: true, | ||
| 14 | + }, common.mustNotCall()); | ||
| 15 | + }, { | ||
| 16 | + code: 'ERR_INVALID_ARG_VALUE', | ||
| 17 | + }); | ||
| 18 | + | ||
| 19 | + assert.throws(() => { | ||
| 20 | + rmdirSync('nonexistent', { | ||
| 21 | + recursive: true, | ||
| 22 | + }); | ||
| 23 | + }, { | ||
| 24 | + code: 'ERR_INVALID_ARG_VALUE', | ||
| 25 | + }); | ||
| 26 | + | ||
| 27 | + rmdirPromise('nonexistent', { | ||
| 28 | + recursive: true, | ||
| 29 | + }).then(common.mustNotCall(), common.mustCall((err) => { | ||
| 30 | + assert.strictEqual(err.code, 'ERR_INVALID_ARG_VALUE'); | ||
| 31 | + })); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments