src/library/rmdir.js   A
last analyzed

Complexity

Total Complexity 4
Complexity/F 2

Size

Lines of Code 17
Function Count 2

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 1
Metric Value
cc 0
c 1
b 1
f 1
nc 1
dl 0
loc 17
rs 10
wmc 4
mnd 2
bc 5
fnc 2
bpm 2.5
cpm 2
noi 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A rmdir.js ➔ ??? 0 13 2
1
import fs from 'fs'
2
3
const deleteFolderRecursive = path => {
4
  if (fs.existsSync(path)) {
5
    fs.readdirSync(path).forEach((file) => {
6
      const curPath = `${path}/${file}`
7
      if (fs.lstatSync(curPath).isDirectory()) {
8
        deleteFolderRecursive(curPath)
9
      } else {
10
        fs.unlinkSync(curPath)
11
      }
12
    })
13
    fs.rmdirSync(path)
14
  }
15
}
16
17
export default deleteFolderRecursive