-
Notifications
You must be signed in to change notification settings - Fork 312
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #158 from jesseshieh/master
Friendly error message when erlang version is not supported
- Loading branch information
Showing
4 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/usr/bin/env bash | ||
|
||
fetch_erlang_versions() { | ||
url="https://raw.githubusercontent.com/HashNuke/heroku-buildpack-elixir-otp-builds/master/otp-versions" | ||
curl -s "$url" | ||
} | ||
|
||
exact_erlang_version_available() { | ||
version=$1 | ||
available_versions=$2 | ||
found=1 | ||
while read -r line; do | ||
if [ "$line" = "$version" ]; then | ||
found=0 | ||
fi | ||
done <<< "$available_versions" | ||
echo $found | ||
} | ||
|
||
check_erlang_version() { | ||
version=$1 | ||
exists=$(exact_erlang_version_available "$version" "$(fetch_erlang_versions)") | ||
if [ $exists -ne 0 ]; then | ||
output_line "Sorry, Erlang $version isn't supported yet. For a list of supported versions, please see https://github.com/HashNuke/heroku-buildpack-elixir#version-support" | ||
exit 1 | ||
fi | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/usr/bin/env bash | ||
|
||
. ${BUILDPACK_TEST_RUNNER_HOME}/lib/test_utils.sh | ||
. ${BUILDPACK_HOME}/lib/canonical_version.sh | ||
|
||
VERSIONS=$(fetch_erlang_versions) | ||
|
||
testExactErlangVersionAvailable() { | ||
assertEquals 0 $(exact_erlang_version_available "22.0.3" "$VERSIONS") | ||
} | ||
|
||
testExactErlangVersionUnavailable() { | ||
assertEquals 1 $(exact_erlang_version_available "22.0.1" "$VERSIONS") | ||
} | ||
|
||
testExactErlangVersionMajorOnly() { | ||
assertEquals 1 $(exact_erlang_version_available "21" "$VERSIONS") | ||
} | ||
|
||
testExactErlangVersionMajorMinorOnly() { | ||
assertEquals 0 $(exact_erlang_version_available "21.0" "$VERSIONS") | ||
} |