diff options
author | Ian Sutherland <ian@iansutherland.ca> | 2020-10-08 15:21:56 -0600 |
---|---|---|
committer | Benjamin Coe <bencoe@google.com> | 2020-10-14 18:56:40 -0700 |
commit | 2002d90abdf91e862294daab90661aa62b4dabe3 (patch) | |
tree | b7f06af2b1fce35ce9b55d4947ede71e31e3a7ce /test/parallel/test-fs-rmdir-recursive-warns-not-found.js | |
parent | ab0af50ef8cd18eff18918cf380ad1127d4c4a24 (diff) | |
download | node-new-2002d90abdf91e862294daab90661aa62b4dabe3.tar.gz |
fs: deprecation warning on recursive rmdir
This is a follow up to #35494 to add a deprecation warning when
using recursive rmdir. This only warns if you are attempting
to remove a file or a nonexistent path.
PR-URL: https://github.com/nodejs/node/pull/35562
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Ben Coe <bencoe@gmail.com>
Reviewed-By: Michael Dawson <midawson@redhat.com>
Diffstat (limited to 'test/parallel/test-fs-rmdir-recursive-warns-not-found.js')
-rw-r--r-- | test/parallel/test-fs-rmdir-recursive-warns-not-found.js | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/test/parallel/test-fs-rmdir-recursive-warns-not-found.js b/test/parallel/test-fs-rmdir-recursive-warns-not-found.js new file mode 100644 index 0000000000..c87a209560 --- /dev/null +++ b/test/parallel/test-fs-rmdir-recursive-warns-not-found.js @@ -0,0 +1,24 @@ +'use strict'; +const common = require('../common'); +const tmpdir = require('../common/tmpdir'); +const fs = require('fs'); +const path = require('path'); + +tmpdir.refresh(); + + +{ + // Should warn when trying to delete a nonexistent path + common.expectWarning( + 'DeprecationWarning', + 'In future versions of Node.js, fs.rmdir(path, { recursive: true }) ' + + 'will throw if path does not exist or is a file. Use fs.rm(path, ' + + '{ recursive: true, force: true }) instead', + 'DEP0147' + ); + fs.rmdir( + path.join(tmpdir.path, 'noexist.txt'), + { recursive: true }, + common.mustCall() + ); +} |