Created
January 25, 2021 12:38
-
-
Save rmb122/1fe4f4a927f1d817a90874e23f292c14 to your computer and use it in GitHub Desktop.
Fuck god damn it node_modules
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import typing | |
import shutil | |
def walk_dirs(path: str, cb: typing.Callable, skip_dot: bool) -> None: | |
try: | |
entries = os.listdir(path) | |
except PermissionError: | |
return | |
for entry in entries: | |
if skip_dot and entry.startswith('.'): | |
continue | |
entry_path = os.path.join(path, entry) | |
if cb(entry, entry_path): | |
if os.path.isdir(entry_path): | |
walk_dirs(entry_path, cb, skip_dot) | |
def fuck_node_modules(entry: str, path: str) -> bool: | |
if entry == 'node_modules': | |
c = input('!!! Do you want to remove [' + path + '] ? [y/N]: ') | |
if c.lower() == 'y': | |
shutil.rmtree(path) | |
return False | |
else: | |
return True | |
walk_dirs('/home/rmb122', fuck_node_modules, True) |
Author
rmb122
commented
Jan 25, 2021
find . -name 'node_modules' \! -path "*/node_modules/*"
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment