-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathremove.py
More file actions
31 lines (25 loc) · 993 Bytes
/
remove.py
File metadata and controls
31 lines (25 loc) · 993 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import argparse
import os, sys, shutil, glob
def arguments(argsval):
parser = argparse.ArgumentParser()
parser.add_argument('-fol', '--folder', type=str, required=False, help="""Specifies the target folder which node_module remover need to act.""")
return parser.parse_args(argsval)
def main(def_args=sys.argv[1:]):
args = arguments(def_args)
directory = args.folder
if directory is None:
directory = './'
remover(directory)
print('done 💪')
def remover(directory):
for directory, dirs, files in os.walk(directory):
for subdir in dirs:
print(os.path.join(directory, subdir))
if subdir == 'node_modules':
try:
print('🤔 removing node_modules, it will take some time. please be patient! ⏳')
shutil.rmtree(os.path.join(directory,subdir))
except Exception as e:
print(e)
if __name__ == "__main__":
main()