Skip to content

Commit 6855735

Browse files
committed
chore(scripts): support sappling in project_root
1 parent 43cc544 commit 6855735

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

scripts/lib.sh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,17 @@ realpath() {
4141
# We have to define realpath before these otherwise it fails on Mac's bash.
4242
SCRIPT="${BASH_SOURCE[1]:-${BASH_SOURCE[0]}}"
4343
SCRIPT_DIR="$(realpath "$(dirname "$SCRIPT")")"
44-
PROJECT_ROOT="$(cd "$SCRIPT_DIR" && realpath "$(git rev-parse --show-toplevel)")"
44+
45+
function project_root {
46+
dir=$(pwd)
47+
48+
while [[ "$dir" != "" && ! -e "$dir/.git" && ! -e "$dir/.sl" ]]; do
49+
dir=${dir%/*}
50+
done
51+
52+
echo "$dir"
53+
}
54+
PROJECT_ROOT="$(cd "$SCRIPT_DIR" && realpath "$(project_root)")"
4555

4656
# pushd is a silent alternative to the real pushd shell command.
4757
pushd() {

0 commit comments

Comments
 (0)