Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions test/parallel/test-fs-rmdir-recursive-sync-warns-not-found.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
'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.rmdirSync(path.join(tmpdir.path, 'noexist.txt'), { recursive: true });
}
21 changes: 21 additions & 0 deletions test/parallel/test-fs-rmdir-recursive-sync-warns-on-file.js
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 });
}
1 change: 0 additions & 1 deletion test/parallel/test-fs-rmdir-recursive-warns-not-found.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const path = require('path');

tmpdir.refresh();


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: we usually try to avoid unrelated whitespace changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to know. I'm pretty sure I accidentally added this extra whitespace in my previous PR so I was just cleaning it up.

{
// Should warn when trying to delete a nonexistent path
common.expectWarning(
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-fs-rmdir-recursive-warns-on-file.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ tmpdir.refresh();
);
const filePath = path.join(tmpdir.path, 'rmdir-recursive.txt');
fs.writeFileSync(filePath, '');
fs.rmdirSync(filePath, { recursive: true });
fs.rmdir(filePath, { recursive: true }, common.mustCall());
}