summaryrefslogtreecommitdiff
path: root/run.sh
diff options
context:
space:
mode:
authormo khan <mo.khan@gmail.com>2020-06-05 15:12:56 -0600
committermo khan <mo.khan@gmail.com>2020-06-05 15:12:56 -0600
commit55d3e5288826e21286054ed7cbaaec15e037f1dd (patch)
treef853dc1c8601fb4222908f2ce8d4e03880367db3 /run.sh
parent2c93d56d5b4d296e00e9007497aa465c2418a8b6 (diff)
Extract function to prepare java and python
Diffstat (limited to 'run.sh')
-rwxr-xr-xrun.sh39
1 files changed, 23 insertions, 16 deletions
diff --git a/run.sh b/run.sh
index aa9371e..8199f9e 100755
--- a/run.sh
+++ b/run.sh
@@ -65,6 +65,26 @@ function prepare_dotnet() {
[[ $(ls ./*.sln 2> /dev/null) ]] && RECURSIVE="--recursive"
}
+function prepare_java() {
+ if [ -n "$LM_JAVA_VERSION" ]; then
+ switch_to java "adopt-openjdk-${LM_JAVA_VERSION}"
+ elif [ -n "$ASDF_JAVA_VERSION" ]; then
+ switch_to_exact java "$ASDF_JAVA_VERSION"
+ else
+ switch_to java "adopt-openjdk-8"
+ fi
+}
+
+function prepare_python() {
+ if [ -n "$LM_PYTHON_VERSION" ]; then
+ switch_to python "$(major_version_from "$LM_PYTHON_VERSION")"
+ elif [ -n "$ASDF_PYTHON_VERSION" ]; then
+ switch_to_exact python "$ASDF_PYTHON_VERSION"
+ else
+ switch_to python "3"
+ fi
+}
+
function prepare_tools() {
if ! asdf current 2> >(grep -q 'is not installed'); then
echo "Installing missing tools…"
@@ -73,6 +93,9 @@ function prepare_tools() {
}
function prepare_project() {
+ prepare_java
+ prepare_python
+
if [[ -z ${SETUP_CMD:-} ]]; then
prepare_tools || true
prepare_dotnet || true
@@ -84,22 +107,6 @@ function prepare_project() {
fi
}
-if [ -n "$LM_JAVA_VERSION" ]; then
- switch_to java "adopt-openjdk-${LM_JAVA_VERSION}"
-elif [ -n "$ASDF_JAVA_VERSION" ]; then
- switch_to_exact java "$ASDF_JAVA_VERSION"
-else
- switch_to java "adopt-openjdk-8"
-fi
-
-if [ -n "$LM_PYTHON_VERSION" ]; then
- switch_to python "$(major_version_from "$LM_PYTHON_VERSION")"
-elif [ -n "$ASDF_PYTHON_VERSION" ]; then
- switch_to_exact python "$ASDF_PYTHON_VERSION"
-else
- switch_to python "3"
-fi
-
prepare_project
[[ $CI_DEBUG_TRACE == 'true' ]] && debug_env