Skip to content

Commit

Permalink
fixup! fs: remove permissive rmdir recursive
Browse files Browse the repository at this point in the history
  • Loading branch information
aduh95 committed Mar 20, 2021
1 parent 8e1e85e commit c0bd783
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions test/parallel/test-fs-rmdir-recursive-throws-on-file.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,23 @@ const path = require('path');

tmpdir.refresh();

const code = common.isWindows ? 'ENOENT' : 'ENOTDIR';

{
const filePath = path.join(tmpdir.path, 'rmdir-recursive.txt');
fs.writeFileSync(filePath, '');
assert.throws(() => fs.rmdirSync(filePath, { recursive: true }), {
code: 'ENOTDIR',
});
assert.throws(() => fs.rmdirSync(filePath, { recursive: true }), { code });
}
{
const filePath = path.join(tmpdir.path, 'rmdir-recursive.txt');
fs.writeFileSync(filePath, '');
fs.rmdir(filePath, { recursive: true }, common.mustCall((err) => {
assert.strictEqual(err.code, 'ENOTDIR');
assert.strictEqual(err.code, code);
}));
}
{
const filePath = path.join(tmpdir.path, 'rmdir-recursive.txt');
fs.writeFileSync(filePath, '');
assert.rejects(() => fs.promises.rmdir(filePath, { recursive: true }), {
code: 'ENOTDIR',
}).then(common.mustCall());
assert.rejects(() => fs.promises.rmdir(filePath, { recursive: true }),
{ code }).then(common.mustCall());
}

0 comments on commit c0bd783

Please sign in to comment.