Skip to content

Instantly share code, notes, and snippets.

@AntoineSebert
Created August 7, 2023 09:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AntoineSebert/831f90753f5f56b778197c4e9aef05cb to your computer and use it in GitHub Desktop.
Save AntoineSebert/831f90753f5f56b778197c4e9aef05cb to your computer and use it in GitHub Desktop.
Removes artifacts from projects in folders and subfolders recursively
function cargo_clean_all() {
# Description: Removes artifacts from projects in folders and subfolders recursively
# Usage: cargo_clean_all [<folder>]
if [ $# -eq 0 ]; then
TARGET_FOLDER="."
else
TARGET_FOLDER=$1
fi
if [ -x "$(command -v fdfind)" ]; then
FILEPATHS=$(fdfind Cargo.toml "${TARGET_FOLDER}")
elif [ -x "$(command -v fd)" ]; then
FILEPATHS=$(fd Cargo.toml "${TARGET_FOLDER}")
else
FILEPATHS=$(find "${TARGET_FOLDER}" -name Cargo.toml)
fi
for filepath in $(echo ${FILEPATHS}); do
echo "cleaning $filepath..."
cargo clean --manifest-path "${filepath}"
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment