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