| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 9fab73c commit 0ddd75b
10 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2671,19 +2671,25 @@ The [`crypto.Certificate()` constructor][] is deprecated. Use | |||
| 2671 | 2671 | ### DEP0147: `fs.rmdir(path, { recursive: true })` | |
| 2672 | 2672 | <!-- YAML | |
| 2673 | 2673 | changes: | |
| 2674 | + - version: REPLACEME | ||
| 2675 | + pr-url: https://github.com/nodejs/node/pull/37302 | ||
| 2676 | + description: Runtime deprecation. | ||
| 2674 | 2677 | - version: v15.0.0 | |
| 2675 | 2678 | pr-url: https://github.com/nodejs/node/pull/35562 | |
| 2676 | - description: Runtime deprecation. | ||
| 2679 | + description: Runtime deprecation for permissive behavior. | ||
| 2677 | 2680 | - version: v14.14.0 | |
| 2678 | 2681 | pr-url: https://github.com/nodejs/node/pull/35579 | |
| 2679 | 2682 | description: Documentation-only deprecation. | |
| 2680 | 2683 | --> | |
| 2681 | 2684 | ||
| 2682 | 2685 | Type: Runtime | |
| 2683 | 2686 | ||
| 2684 | - In future versions of Node.js, `fs.rmdir(path, { recursive: true })` will throw | ||
| 2685 | - if `path` does not exist or is a file. | ||
| 2686 | - Use `fs.rm(path, { recursive: true, force: true })` instead. | ||
| 2687 | + In future versions of Node.js, `recursive` option will be ignored for | ||
| 2688 | + `fs.rmdir`, `fs.rmdirSync`, and `fs.promises.rmdir`. | ||
| 2689 | + | ||
| 2690 | + Use `fs.rm(path, { recursive: true, force: true })`, | ||
| 2691 | + `fs.rmSync(path, { recursive: true, force: true })` or | ||
| 2692 | + `fs.promises.rm(path, { recursive: true, force: true })` instead. | ||
| 2687 | 2693 | ||
| 2688 | 2694 | ### DEP0148: Folder mappings in `"exports"` (trailing `"/"`) | |
| 2689 | 2695 | <!-- YAML | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1048,6 +1048,10 @@ Renames `oldPath` to `newPath`. | |||
| 1048 | 1048 | <!-- YAML | |
| 1049 | 1049 | added: v10.0.0 | |
| 1050 | 1050 | changes: | |
| 1051 | + - version: REPLACEME | ||
| 1052 | + pr-url: https://github.com/nodejs/node/pull/37302 | ||
| 1053 | + description: The `recursive` option is deprecated, using it triggers a | ||
| 1054 | + deprecation warning. | ||
| 1051 | 1055 | - version: | |
| 1052 | 1056 | - v13.3.0 | |
| 1053 | 1057 | - v12.16.0 | |
@@ -1072,7 +1076,7 @@ changes: | |||
| 1072 | 1076 | option is not `true`. **Default:** `0`. | |
| 1073 | 1077 | * `recursive` {boolean} If `true`, perform a recursive directory removal. In | |
| 1074 | 1078 | recursive mode, errors are not reported if `path` does not exist, and | |
| 1075 | - operations are retried on failure. **Default:** `false`. | ||
| 1079 | + operations are retried on failure. **Default:** `false`. **Deprecated**. | ||
| 1076 | 1080 | * `retryDelay` {integer} The amount of time in milliseconds to wait between | |
| 1077 | 1081 | retries. This option is ignored if the `recursive` option is not `true`. | |
| 1078 | 1082 | **Default:** `100`. | |
@@ -1086,9 +1090,8 @@ error on POSIX. | |||
| 1086 | 1090 | ||
| 1087 | 1091 | Setting `recursive` to `true` results in behavior similar to the Unix command | |
| 1088 | 1092 | `rm -rf`: an error will not be raised for paths that do not exist, and paths | |
| 1089 | - that represent files will be deleted. The permissive behavior of the | ||
| 1090 | - `recursive` option is deprecated, `ENOTDIR` and `ENOENT` will be thrown in | ||
| 1091 | - the future. | ||
| 1093 | + that represent files will be deleted. The `recursive` option is deprecated, | ||
| 1094 | + `ENOTDIR` and `ENOENT` will be thrown in the future. | ||
| 1092 | 1095 | ||
| 1093 | 1096 | ### `fsPromises.rm(path[, options])` | |
| 1094 | 1097 | <!-- YAML | |
@@ -3135,6 +3138,10 @@ rename('oldFile.txt', 'newFile.txt', (err) => { | |||
| 3135 | 3138 | <!-- YAML | |
| 3136 | 3139 | added: v0.0.2 | |
| 3137 | 3140 | changes: | |
| 3141 | + - version: REPLACEME | ||
| 3142 | + pr-url: https://github.com/nodejs/node/pull/37302 | ||
| 3143 | + description: The `recursive` option is deprecated, using it triggers a | ||
| 3144 | + deprecation warning. | ||
| 3138 | 3145 | - version: | |
| 3139 | 3146 | - v13.3.0 | |
| 3140 | 3147 | - v12.16.0 | |
@@ -3171,7 +3178,7 @@ changes: | |||
| 3171 | 3178 | option is not `true`. **Default:** `0`. | |
| 3172 | 3179 | * `recursive` {boolean} If `true`, perform a recursive directory removal. In | |
| 3173 | 3180 | recursive mode, errors are not reported if `path` does not exist, and | |
| 3174 | - operations are retried on failure. **Default:** `false`. | ||
| 3181 | + operations are retried on failure. **Default:** `false`. **Deprecated**. | ||
| 3175 | 3182 | * `retryDelay` {integer} The amount of time in milliseconds to wait between | |
| 3176 | 3183 | retries. This option is ignored if the `recursive` option is not `true`. | |
| 3177 | 3184 | **Default:** `100`. | |
@@ -3186,9 +3193,8 @@ Windows and an `ENOTDIR` error on POSIX. | |||
| 3186 | 3193 | ||
| 3187 | 3194 | Setting `recursive` to `true` results in behavior similar to the Unix command | |
| 3188 | 3195 | `rm -rf`: an error will not be raised for paths that do not exist, and paths | |
| 3189 | - that represent files will be deleted. The permissive behavior of the | ||
| 3190 | - `recursive` option is deprecated, `ENOTDIR` and `ENOENT` will be thrown in | ||
| 3191 | - the future. | ||
| 3196 | + that represent files will be deleted. The `recursive` option is deprecated, | ||
| 3197 | + `ENOTDIR` and `ENOENT` will be thrown in the future. | ||
| 3192 | 3198 | ||
| 3193 | 3199 | ### `fs.rm(path[, options], callback)` | |
| 3194 | 3200 | <!-- YAML | |
@@ -4755,6 +4761,10 @@ See the POSIX rename(2) documentation for more details. | |||
| 4755 | 4761 | <!-- YAML | |
| 4756 | 4762 | added: v0.1.21 | |
| 4757 | 4763 | changes: | |
| 4764 | + - version: REPLACEME | ||
| 4765 | + pr-url: https://github.com/nodejs/node/pull/37302 | ||
| 4766 | + description: The `recursive` option is deprecated, using it triggers a | ||
| 4767 | + deprecation warning. | ||
| 4758 | 4768 | - version: | |
| 4759 | 4769 | - v13.3.0 | |
| 4760 | 4770 | - v12.16.0 | |
@@ -4783,7 +4793,7 @@ changes: | |||
| 4783 | 4793 | option is not `true`. **Default:** `0`. | |
| 4784 | 4794 | * `recursive` {boolean} If `true`, perform a recursive directory removal. In | |
| 4785 | 4795 | recursive mode, errors are not reported if `path` does not exist, and | |
| 4786 | - operations are retried on failure. **Default:** `false`. | ||
| 4796 | + operations are retried on failure. **Default:** `false`. **Deprecated**. | ||
| 4787 | 4797 | * `retryDelay` {integer} The amount of time in milliseconds to wait between | |
| 4788 | 4798 | retries. This option is ignored if the `recursive` option is not `true`. | |
| 4789 | 4799 | **Default:** `100`. | |
@@ -4795,9 +4805,8 @@ on Windows and an `ENOTDIR` error on POSIX. | |||
| 4795 | 4805 | ||
| 4796 | 4806 | Setting `recursive` to `true` results in behavior similar to the Unix command | |
| 4797 | 4807 | `rm -rf`: an error will not be raised for paths that do not exist, and paths | |
| 4798 | - that represent files will be deleted. The permissive behavior of the | ||
| 4799 | - `recursive` option is deprecated, `ENOTDIR` and `ENOENT` will be thrown in | ||
| 4800 | - the future. | ||
| 4808 | + that represent files will be deleted. The `recursive` option is deprecated, | ||
| 4809 | + `ENOTDIR` and `ENOENT` will be thrown in the future. | ||
| 4801 | 4810 | ||
| 4802 | 4811 | ### `fs.rmSync(path[, options])` | |
| 4803 | 4812 | <!-- YAML | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -91,6 +91,7 @@ const internalUtil = require('internal/util'); | |||
| 91 | 91 | const { | |
| 92 | 92 | copyObject, | |
| 93 | 93 | Dirent, | |
| 94 | + emitRecursiveRmdirWarning, | ||
| 94 | 95 | getDirents, | |
| 95 | 96 | getOptions, | |
| 96 | 97 | getValidatedFd, | |
@@ -893,6 +894,7 @@ function rmdir(path, options, callback) { | |||
| 893 | 894 | path = pathModule.toNamespacedPath(getValidatedPath(path)); | |
| 894 | 895 | ||
| 895 | 896 | if (options?.recursive) { | |
| 897 | + emitRecursiveRmdirWarning(); | ||
| 896 | 898 | validateRmOptions( | |
| 897 | 899 | path, | |
| 898 | 900 | { ...options, force: true }, | |
@@ -917,6 +919,7 @@ function rmdirSync(path, options) { | |||
| 917 | 919 | path = getValidatedPath(path); | |
| 918 | 920 | ||
| 919 | 921 | if (options?.recursive) { | |
| 922 | + emitRecursiveRmdirWarning(); | ||
| 920 | 923 | options = validateRmOptionsSync(path, { ...options, force: true }, true); | |
| 921 | 924 | lazyLoadRimraf(); | |
| 922 | 925 | return rimrafSync(pathModule.toNamespacedPath(path), options); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -46,6 +46,7 @@ const { isArrayBufferView } = require('internal/util/types'); | |||
| 46 | 46 | const { rimrafPromises } = require('internal/fs/rimraf'); | |
| 47 | 47 | const { | |
| 48 | 48 | copyObject, | |
| 49 | + emitRecursiveRmdirWarning, | ||
| 49 | 50 | getDirents, | |
| 50 | 51 | getOptions, | |
| 51 | 52 | getStatsFromBinding, | |
@@ -503,6 +504,7 @@ async function rmdir(path, options) { | |||
| 503 | 504 | options = validateRmdirOptions(options); | |
| 504 | 505 | ||
| 505 | 506 | if (options.recursive) { | |
| 507 | + emitRecursiveRmdirWarning(); | ||
| 506 | 508 | return rimrafPromises(path, options); | |
| 507 | 509 | } | |
| 508 | 510 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -705,18 +705,11 @@ const validateRmOptions = hideStackFrames((path, options, warn, callback) => { | |||
| 705 | 705 | lazyLoadFs().stat(path, (err, stats) => { | |
| 706 | 706 | if (err) { | |
| 707 | 707 | if (options.force && err.code === 'ENOENT') { | |
| 708 | - if (warn) { | ||
| 709 | - emitPermissiveRmdirWarning(); | ||
| 710 | - } | ||
| 711 | 708 | return callback(null, options); | |
| 712 | 709 | } | |
| 713 | 710 | return callback(err, options); | |
| 714 | 711 | } | |
| 715 | 712 | ||
| 716 | - if (warn && !stats.isDirectory()) { | ||
| 717 | - emitPermissiveRmdirWarning(); | ||
| 718 | - } | ||
| 719 | - | ||
| 720 | 713 | if (stats.isDirectory() && !options.recursive) { | |
| 721 | 714 | return callback(new ERR_FS_EISDIR({ | |
| 722 | 715 | code: 'EISDIR', | |
@@ -738,10 +731,6 @@ const validateRmOptionsSync = hideStackFrames((path, options, warn) => { | |||
| 738 | 731 | const isDirectory = lazyLoadFs() | |
| 739 | 732 | .statSync(path, { throwIfNoEntry: !options.force })?.isDirectory(); | |
| 740 | 733 | ||
| 741 | - if (warn && !isDirectory) { | ||
| 742 | - emitPermissiveRmdirWarning(); | ||
| 743 | - } | ||
| 744 | - | ||
| 745 | 734 | if (isDirectory && !options.recursive) { | |
| 746 | 735 | throw new ERR_FS_EISDIR({ | |
| 747 | 736 | code: 'EISDIR', | |
@@ -756,18 +745,16 @@ const validateRmOptionsSync = hideStackFrames((path, options, warn) => { | |||
| 756 | 745 | return options; | |
| 757 | 746 | }); | |
| 758 | 747 | ||
| 759 | - let permissiveRmdirWarned = false; | ||
| 760 | - | ||
| 761 | - function emitPermissiveRmdirWarning() { | ||
| 762 | - if (!permissiveRmdirWarned) { | ||
| 748 | + let recursiveRmdirWarned = process.noDeprecation; | ||
| 749 | + function emitRecursiveRmdirWarning() { | ||
| 750 | + if (!recursiveRmdirWarned) { | ||
| 763 | 751 | process.emitWarning( | |
| 764 | 752 | 'In future versions of Node.js, fs.rmdir(path, { recursive: true }) ' + | |
| 765 | - 'will throw if path does not exist or is a file. Use fs.rm(path, ' + | ||
| 766 | - '{ recursive: true, force: true }) instead', | ||
| 753 | + 'will be removed. Use fs.rm(path, { recursive: true }) instead', | ||
| 767 | 754 | 'DeprecationWarning', | |
| 768 | 755 | 'DEP0147' | |
| 769 | 756 | ); | |
| 770 | - permissiveRmdirWarned = true; | ||
| 757 | + recursiveRmdirWarned = true; | ||
| 771 | 758 | } | |
| 772 | 759 | } | |
| 773 | 760 | ||
@@ -852,6 +839,7 @@ module.exports = { | |||
| 852 | 839 | BigIntStats, // for testing | |
| 853 | 840 | copyObject, | |
| 854 | 841 | Dirent, | |
| 842 | + emitRecursiveRmdirWarning, | ||
| 855 | 843 | getDirent, | |
| 856 | 844 | getDirents, | |
| 857 | 845 | getOptions, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11,8 +11,7 @@ tmpdir.refresh(); | |||
| 11 | 11 | common.expectWarning( | |
| 12 | 12 | 'DeprecationWarning', | |
| 13 | 13 | 'In future versions of Node.js, fs.rmdir(path, { recursive: true }) ' + | |
| 14 | - 'will throw if path does not exist or is a file. Use fs.rm(path, ' + | ||
| 15 | - '{ recursive: true, force: true }) instead', | ||
| 14 | + 'will be removed. Use fs.rm(path, { recursive: true }) instead', | ||
| 16 | 15 | 'DEP0147' | |
| 17 | 16 | ); | |
| 18 | 17 | fs.rmdirSync(path.join(tmpdir.path, 'noexist.txt'), { recursive: true }); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11,8 +11,7 @@ tmpdir.refresh(); | |||
| 11 | 11 | common.expectWarning( | |
| 12 | 12 | 'DeprecationWarning', | |
| 13 | 13 | 'In future versions of Node.js, fs.rmdir(path, { recursive: true }) ' + | |
| 14 | - 'will throw if path does not exist or is a file. Use fs.rm(path, ' + | ||
| 15 | - '{ recursive: true, force: true }) instead', | ||
| 14 | + 'will be removed. Use fs.rm(path, { recursive: true }) instead', | ||
| 16 | 15 | 'DEP0147' | |
| 17 | 16 | ); | |
| 18 | 17 | const filePath = path.join(tmpdir.path, 'rmdir-recursive.txt'); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11,8 +11,7 @@ tmpdir.refresh(); | |||
| 11 | 11 | common.expectWarning( | |
| 12 | 12 | 'DeprecationWarning', | |
| 13 | 13 | 'In future versions of Node.js, fs.rmdir(path, { recursive: true }) ' + | |
| 14 | - 'will throw if path does not exist or is a file. Use fs.rm(path, ' + | ||
| 15 | - '{ recursive: true, force: true }) instead', | ||
| 14 | + 'will be removed. Use fs.rm(path, { recursive: true }) instead', | ||
| 16 | 15 | 'DEP0147' | |
| 17 | 16 | ); | |
| 18 | 17 | fs.rmdir( | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11,8 +11,7 @@ tmpdir.refresh(); | |||
| 11 | 11 | common.expectWarning( | |
| 12 | 12 | 'DeprecationWarning', | |
| 13 | 13 | 'In future versions of Node.js, fs.rmdir(path, { recursive: true }) ' + | |
| 14 | - 'will throw if path does not exist or is a file. Use fs.rm(path, ' + | ||
| 15 | - '{ recursive: true, force: true }) instead', | ||
| 14 | + 'will be removed. Use fs.rm(path, { recursive: true }) instead', | ||
| 16 | 15 | 'DEP0147' | |
| 17 | 16 | ); | |
| 18 | 17 | const filePath = path.join(tmpdir.path, 'rmdir-recursive.txt'); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,6 +7,13 @@ const fs = require('fs'); | |||
| 7 | 7 | const path = require('path'); | |
| 8 | 8 | const { validateRmdirOptions } = require('internal/fs/utils'); | |
| 9 | 9 | ||
| 10 | + common.expectWarning( | ||
| 11 | + 'DeprecationWarning', | ||
| 12 | + 'In future versions of Node.js, fs.rmdir(path, { recursive: true }) ' + | ||
| 13 | + 'will be removed. Use fs.rm(path, { recursive: true }) instead', | ||
| 14 | + 'DEP0147' | ||
| 15 | + ); | ||
| 16 | + | ||
| 10 | 17 | tmpdir.refresh(); | |
| 11 | 18 | ||
| 12 | 19 | let count = 0; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments