MCPcopy Create free account
hub / github.com/isomorphic-git/isomorphic-git / rmRecursive

Function rmRecursive

src/utils/rmRecursive.js:11–28  ·  view source on GitHub ↗
(fs, filepath)

Source from the content-addressed store, hash-verified

9 * @param {string} filepath - The file or directory to remove.
10 */
11export async function rmRecursive(fs, filepath) {
12 const entries = await fs.readdir(filepath)
13 if (entries == null) {
14 await fs.rm(filepath)
15 } else if (entries.length) {
16 await Promise.all(
17 entries.map(entry => {
18 const subpath = join(filepath, entry)
19 return fs.lstat(subpath).then(stat => {
20 if (!stat) return
21 return stat.isDirectory() ? rmRecursive(fs, subpath) : fs.rm(subpath)
22 })
23 })
24 ).then(() => fs.rmdir(filepath))
25 } else {
26 await fs.rmdir(filepath)
27 }
28}

Callers

nothing calls this directly

Calls 5

joinFunction · 0.90
rmMethod · 0.80
lstatMethod · 0.80
rmdirMethod · 0.80
readdirMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…