Skip to content

Commit 33301a0

Browse files
committed
feat(cli): add root option
1 parent 1bd8289 commit 33301a0

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ clean-cache -n
5151
clean-cache -h
5252
```
5353

54+
#### 清除根目录
55+
56+
```shell
57+
clean-cache -r
58+
```
59+
5460
<br />
5561

5662
## License

README_EN.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ clean-cache -n
5151
clean-cache -h
5252
```
5353

54+
#### clean root
55+
56+
```shell
57+
clean-cache -r
58+
```
59+
5460
<br />
5561

5662
## License

main.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,20 @@ func withDist(dirs *[]string) {
3333
}
3434
}
3535

36+
func withAppend(dirs *[]string) {
37+
for _, v := range os.Args {
38+
if v == "-r" || v == "--root" {
39+
*dirs = append(*dirs, "./")
40+
return
41+
}
42+
}
43+
}
44+
3645
func main() {
3746
if isHelp() {
3847
fmt.Print("\n")
3948
color.Cyan("clean-cache\n\n")
49+
fmt.Print(" -r --root 删除根目录\n\n")
4050
fmt.Print("Description: go 写的清理 node 项目缓存,超级无敌快\n\n")
4151
fmt.Print("Usage: -d --dist 则会删除 dist 和 .output\n\n")
4252
fmt.Print(" -n --node_modules 则会删除 node_modules\n\n")
@@ -45,6 +55,8 @@ func main() {
4555

4656
cacheDirs := []string{".nuxt", "cache", ".cache", "@cache", "temp", ".temp", "@temp"}
4757

58+
withAppend(&cacheDirs)
59+
4860
withDist(&cacheDirs)
4961

5062
withNodeModules(&cacheDirs)

0 commit comments

Comments
 (0)