diff --git a/ensure-rebar3.sh b/ensure-rebar3.sh index 626dd1bc1..0d77be44a 100755 --- a/ensure-rebar3.sh +++ b/ensure-rebar3.sh @@ -5,12 +5,16 @@ set -euo pipefail VERSION="$1" DOWNLOAD_URL='https://github.com/emqx/rebar3/releases/download' + download() { curl -L "${DOWNLOAD_URL}/${VERSION}/rebar3" -o ./rebar3 } +# get the version number from the second line of the escript +# because command `rebar3 -v` tries to load rebar.config +# which is slow and may print some logs version() { - ./rebar3 -v | grep -v '===' | grep 'rebar.*Erlang' | awk '{print $2}' + head -n 2 ./rebar3 | tail -n 1 | tr ' ' '\n' | grep -E '^.+-emqx-.+' } if [ -f 'rebar3' ] && [ "$(version)" == "$VERSION" ]; then