Created
July 25, 2022 21:23
-
-
Save antoinevg/494ae08d82ed1f0c428e736c36149b47 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env python3 | |
import os | |
import shutil | |
import subprocess | |
dir = '<your projects root>' | |
print('Cleaning rust projects in ' + dir + ' and all its subfolders.') | |
for dirpath, dirnames, filenames in os.walk(dir): | |
for directory in dirnames: | |
if directory.startswith('.'): | |
continue | |
# assume it's a rust project if directory has a target/ folder | |
if directory == 'target': | |
print('Running `cargo clean` in: ' + dirpath) | |
command = ['cargo', 'clean'] | |
with subprocess.Popen(command, cwd=dirpath, stdout=subprocess.PIPE, bufsize=1, universal_newlines=True) as p: | |
for line in p.stdout: | |
print(line, end='') | |
print('Task completed!') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment