@@ -16,27 +16,38 @@ func isHelp() bool {
1616 return false
1717}
1818
19- func withNodeModules (dirs []string ) [] string {
19+ func withNodeModules (dirs * []string ) {
2020 for _ , v := range os .Args {
2121 if v == "-n" || v == "--node_modules" {
22- return append (dirs , "node_modules" )
22+ * dirs = append (* dirs , "node_modules" )
23+ }
24+ }
25+ }
26+
27+ func withDist (dirs * []string ) {
28+ for _ , v := range os .Args {
29+ if v == "-d" || v == "--dist" {
30+ * dirs = append (* dirs , "dist" , ".output" )
31+ return
2332 }
2433 }
25- return dirs
2634}
2735
2836func main () {
2937 if isHelp () {
3038 fmt .Print ("\n " )
3139 color .Cyan ("clean-cache\n \n " )
3240 fmt .Print ("Description: go 写的清理 node 项目缓存,超级无敌快\n \n " )
33- fmt .Print ("Usage: -n --node_modules 则会删除 node_modules\n \n " )
41+ fmt .Print ("Usage: -d --dist 则会删除 dist 和 .output\n \n " )
42+ fmt .Print (" -n --node_modules 则会删除 node_modules\n \n " )
3443 os .Exit (0 )
3544 }
3645
37- cache_dirs := []string {".nuxt" , "cache" , ".cache" , "@cache" , "temp" , ".temp" , "@temp" , "dist" , ".output" }
46+ cache_dirs := []string {".nuxt" , "cache" , ".cache" , "@cache" , "temp" , ".temp" , "@temp" }
47+
48+ withDist (& cache_dirs )
3849
39- cache_dirs = withNodeModules (cache_dirs )
50+ withNodeModules (& cache_dirs )
4051
4152 for _ , v := range cache_dirs {
4253 if ! IsExist (v ) || ! IsDir (v ) {
0 commit comments