diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ae81dc5017..746e34806a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -79,8 +79,7 @@ Open a pull request against the main repo. > **Note** -> It is recommended to run [pre-commit script](scripts/precommit.sh) from the root of -the repo to catch any issues locally. +> It is recommended to run [pre-commit script](scripts/precommit.sh) to catch any issues locally. ### How to Receive Comments diff --git a/scripts/precommit.sh b/scripts/precommit.sh index 0144ba8a36..1c209eedf4 100755 --- a/scripts/precommit.sh +++ b/scripts/precommit.sh @@ -1 +1,7 @@ -cargo update && cargo fmt --all && ./scripts/lint.sh && ./scripts/test.sh \ No newline at end of file +REPO_ROOT=$(dirname $( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )) + +pushd "${REPO_ROOT}" > /dev/null + +cargo update && cargo fmt --all && ./scripts/lint.sh && ./scripts/test.sh + +popd > /dev/null \ No newline at end of file