Sha256: 166b6c9abe5cdede8d1008e09eadf4d6f5a1c7dd585e5aaf7c0f88f55b589a27

Contents?: true

Size: 1.14 KB

Versions: 4

Compression:

Stored size: 1.14 KB

Contents

#!/bin/bash
# Deployed by danarchy_deploy
#   manages system-wide asdf; still allows for local ~/.asdf

function _run_now() {
    tmp_file=/tmp/asdf_next_run.tmp
    next_run=$(cat ${tmp_file} 2>/dev/null || echo 0)

    if [[ $(date '+%s') -gt ${next_run} ]]; then
        echo 'true'
    else
        echo 'false'
    fi
}

function _load_asdf() {
    path=${1}
    export ASDF_DATA_DIR=${path}
    source ${path}/asdf.sh
    source ${path}/completions/asdf.bash
}

if [[ ${UID} == 0 && $(_run_now) == 'true' ]]; then
    if [[ ! -d /opt/asdf ]]; then
        git clone https://github.com/asdf-vm/asdf.git /opt/asdf
    fi

    asdf update >/dev/null 2>&1
    _load_asdf /opt/asdf

    <%- @variables.each do |lang, versions| -%>
    asdf plugin add <%= lang -%>

    <%- versions.each do |version| -%>
    asdf install <%= lang -%> <%= version -%>
    <% end %>

    asdf global <%= lang %> <%= versions.first -%>
    <% end %>

    date -d '1 hour' '+%s' > /tmp/asdf_next_run.tmp
    asdf current
fi

if [[ -d ${HOME}/.asdf ]]; then
    _load_asdf ${HOME}/.asdf
elif [[ -d /opt/asdf ]]; then
    _load_asdf /opt/asdf
fi

unset -f _run_now
unset -f _load_asdf

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
danarchy_deploy-0.2.11 templates/asdf/asdf.sh.erb
danarchy_deploy-0.2.10 templates/asdf/asdf.sh.erb
danarchy_deploy-0.2.9 templates/asdf/asdf.sh.erb
danarchy_deploy-0.2.8 templates/asdf/asdf.sh.erb