aboutsummaryrefslogtreecommitdiff
path: root/fish/functions/_nvm_index_update.fish
blob: c66753d0ec3e849068165e9f65642071c2daf66e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
function _nvm_index_update
    test ! -d $nvm_data && command mkdir -p $nvm_data

    set --local index $nvm_data/.index

    if not command curl -q --location --silent $nvm_mirror/index.tab >$index.temp
        command rm -f $index.temp
        echo "nvm: Can't update index, host unavailable: \"$nvm_mirror\"" >&2
        return 1
    end

    command awk -v OFS=\t '
        /v0.9.12/ { exit } # Unsupported
        NR > 1 {
            print $1 (NR == 2  ? " latest" : $10 != "-" ? " lts/" tolower($10) : "")
        }
    ' $index.temp >$index

    command rm -f $index.temp
end