forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fs: deprecation warning on recursive rmdir
This is a follow up to nodejs#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: nodejs#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>
- Loading branch information
Showing
6 changed files
with
95 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
'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 file | ||
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' | ||
); | ||
const filePath = path.join(tmpdir.path, 'rmdir-recursive.txt'); | ||
fs.writeFileSync(filePath, ''); | ||
fs.rmdirSync(filePath, { recursive: true }); | ||
} |