File tree 1 file changed +37
-0
lines changed
1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change
1
+ const { resolve } = require ( "path" ) ;
2
+ const { readdir, rmdir } = require ( "fs" ) . promises ;
3
+
4
+ async function * removeFolder ( dir ) {
5
+ await rmdir ( dir , { recursive : true } ) ;
6
+ yield dir ;
7
+ }
8
+
9
+ async function * getBinObj ( dir ) {
10
+ const dirents = await readdir ( dir , { withFileTypes : true } ) ;
11
+
12
+ for ( const dirent of dirents ) {
13
+ if ( ! dirent . isDirectory ( ) ) continue ;
14
+ const name = dirent . name ;
15
+
16
+ if ( name === "node_modules" ) continue ;
17
+
18
+ const res = resolve ( dir , dirent . name ) ;
19
+
20
+ if ( name === "bin" || name === "obj" ) {
21
+ yield * removeFolder ( res ) ;
22
+ continue ;
23
+ }
24
+
25
+ yield * getBinObj ( res ) ;
26
+ }
27
+ }
28
+
29
+ ( async ( ) => {
30
+ console . log ( "\x1b[36m%s\x1b[0m" , "Deleting all BIN and OBJ folders..." ) ;
31
+
32
+ for await ( const dir of getBinObj ( "." ) ) {
33
+ console . log ( "\x1b[33m%s\x1b[0m" , `Removed: ${ dir } ` ) ;
34
+ }
35
+
36
+ console . log ( "\x1b[36m%s\x1b[0m" , "All BIN and OBJ folders are deleted." ) ;
37
+ } ) ( ) ;
You can’t perform that action at this time.
0 commit comments