diff --git a/test/parallel/test-fs-rm.js b/test/parallel/test-fs-rm.js index e0e3fd88544fff..d8e24d7e98e121 100644 --- a/test/parallel/test-fs-rm.js +++ b/test/parallel/test-fs-rm.js @@ -130,6 +130,17 @@ function removeAsync(dir) { })); } +// Removing a .git directory should not throw an EPERM. +// Refs: https://github.com/isaacs/rimraf/issues/21. +{ + const gitDirectory = nextDirPath(); + fs.mkdirSync(gitDirectory); + execSync(`git -C ${gitDirectory} init`); + fs.rm(gitDirectory, { recursive: true }, common.mustSucceed(() => { + assert.strictEqual(fs.existsSync(gitDirectory), false); + })); +} + // Test the synchronous version. { const dir = nextDirPath(); @@ -179,6 +190,16 @@ function removeAsync(dir) { assert.throws(() => fs.rmSync(dir), { syscall: 'stat' }); } +// Removing a .git directory should not throw an EPERM. +// Refs: https://github.com/isaacs/rimraf/issues/21. +{ + const gitDirectory = nextDirPath(); + fs.mkdirSync(gitDirectory); + execSync(`git -C ${gitDirectory} init`); + fs.rmSync(gitDirectory, { recursive: true }); + assert.strictEqual(fs.existsSync(gitDirectory), false); +} + // Test the Promises based version. (async () => { const dir = nextDirPath(); @@ -230,6 +251,16 @@ function removeAsync(dir) { } })().then(common.mustCall()); +// Removing a .git directory should not throw an EPERM. +// Refs: https://github.com/isaacs/rimraf/issues/21. +(async () => { + const gitDirectory = nextDirPath(); + fs.mkdirSync(gitDirectory); + execSync(`git -C ${gitDirectory} init`); + await fs.promises.rm(gitDirectory, { recursive: true }); + assert.strictEqual(fs.existsSync(gitDirectory), false); +})().then(common.mustCall()); + // Test input validation. { const dir = nextDirPath();