From fd384a91eafb851dcc4524fab85aa0fa75f4f60e Mon Sep 17 00:00:00 2001 From: Michael Wolf Date: Sat, 30 Sep 2023 17:17:00 -0600 Subject: [PATCH] Recycle project_root output --- _reformat-common.bash | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/_reformat-common.bash b/_reformat-common.bash index f0dcec2..fd2e87d 100644 --- a/_reformat-common.bash +++ b/_reformat-common.bash @@ -16,8 +16,16 @@ function get_os() { # For a given file, return its corresponding project root. function project_root() { + set +u + if [[ ! -z "${PROJECT_ROOT}" ]]; then + echo "$PROJECT_ROOT" + return 0 + fi + set -u + pushd "$(dirname "$1")" >/dev/null 2>&1 || exit 101 out=$(git rev-parse --show-toplevel) + ret="$?" popd >/dev/null 2>&1 || exit 1