Last active
November 10, 2022 20:36
-
-
Save tgolsson/3b5b6c650ebddb75092b3bd115f616bc to your computer and use it in GitHub Desktop.
Pants command
This file contains 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 bash | |
find_parent_pants() { | |
path="$1" | |
while [ `realpath "$path"` != "/" ]; do | |
if [[ -f "$path/pants.toml" ]] ; then | |
if [[ -f "$path/pants_with_source" ]] ; then | |
echo "$path/pants_with_source" | |
else | |
echo "$path/pants" | |
fi | |
return 0 | |
fi | |
path="$path/.." | |
done | |
return 1 | |
} | |
pants=$(find_parent_pants ".") | |
if [[ $? -ne 0 ]]; then | |
echo "Not in a pants workspace: no pants.toml found in this or parent directories" | |
exit 1 | |
fi | |
"$pants" $@ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
New version 2022-11-10 to support
pants_with_source
.