chore(scripts): support sappling in project_root

This commit is contained in:
Ammar Bandukwala 2023-07-23 19:34:44 +00:00
parent 43cc5449a1
commit 6855735085
1 changed files with 11 additions and 1 deletions

View File

@ -41,7 +41,17 @@ realpath() {
# We have to define realpath before these otherwise it fails on Mac's bash.
SCRIPT="${BASH_SOURCE[1]:-${BASH_SOURCE[0]}}"
SCRIPT_DIR="$(realpath "$(dirname "$SCRIPT")")"
PROJECT_ROOT="$(cd "$SCRIPT_DIR" && realpath "$(git rev-parse --show-toplevel)")"
function project_root {
dir=$(pwd)
while [[ "$dir" != "" && ! -e "$dir/.git" && ! -e "$dir/.sl" ]]; do
dir=${dir%/*}
done
echo "$dir"
}
PROJECT_ROOT="$(cd "$SCRIPT_DIR" && realpath "$(project_root)")"
# pushd is a silent alternative to the real pushd shell command.
pushd() {