-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fs: remove permissive rmdir recursive
PR-URL: #37216 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ben Coe <bencoe@gmail.com> Reviewed-By: Ian Sutherland <ian@iansutherland.ca> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Michael Dawson <midawson@redhat.com>
- Loading branch information
Showing
10 changed files
with
167 additions
and
43 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
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,36 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
const tmpdir = require('../common/tmpdir'); | ||
const assert = require('assert'); | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
tmpdir.refresh(); | ||
|
||
{ | ||
assert.throws( | ||
() => | ||
fs.rmdirSync(path.join(tmpdir.path, 'noexist.txt'), { recursive: true }), | ||
{ | ||
code: 'ENOENT', | ||
} | ||
); | ||
} | ||
{ | ||
fs.rmdir( | ||
path.join(tmpdir.path, 'noexist.txt'), | ||
{ recursive: true }, | ||
common.mustCall((err) => { | ||
assert.strictEqual(err.code, 'ENOENT'); | ||
}) | ||
); | ||
} | ||
{ | ||
assert.rejects( | ||
() => fs.promises.rmdir(path.join(tmpdir.path, 'noexist.txt'), | ||
{ recursive: true }), | ||
{ | ||
code: 'ENOENT', | ||
} | ||
).then(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,29 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
const tmpdir = require('../common/tmpdir'); | ||
const assert = require('assert'); | ||
const fs = require('fs'); | ||
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 }); | ||
} | ||
{ | ||
const filePath = path.join(tmpdir.path, 'rmdir-recursive.txt'); | ||
fs.writeFileSync(filePath, ''); | ||
fs.rmdir(filePath, { recursive: true }, common.mustCall((err) => { | ||
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 }).then(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
Oops, something went wrong.