Compare commits
No commits in common. "master" and "1.0.0" have entirely different histories.
1 changed files with 7 additions and 22 deletions
29
direnvrc
29
direnvrc
|
@ -1,7 +1,7 @@
|
||||||
# vi: ft=sh
|
# vi: ft=sh
|
||||||
# shellcheck shell=bash
|
# shellcheck shell=bash
|
||||||
|
|
||||||
ZVM_DIRENV_VERSION=2.0.0
|
ZVM_DIRENV_VERSION=1.0.0
|
||||||
|
|
||||||
# Usage: zvm_direnv_version <version_at_least>
|
# Usage: zvm_direnv_version <version_at_least>
|
||||||
#
|
#
|
||||||
|
@ -20,7 +20,6 @@ _require_version() {
|
||||||
}
|
}
|
||||||
|
|
||||||
use_zig() {
|
use_zig() {
|
||||||
# ZVM_SET_CU will turn off the upgrade check
|
|
||||||
if [[ -z $1 ]]; then
|
if [[ -z $1 ]]; then
|
||||||
log_error "Must specify a zig version!"
|
log_error "Must specify a zig version!"
|
||||||
return 1
|
return 1
|
||||||
|
@ -34,36 +33,22 @@ use_zig() {
|
||||||
log_error "zvm not installed - please install it from https://www.zvm.app/"
|
log_error "zvm not installed - please install it from https://www.zvm.app/"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
local state_dir
|
|
||||||
if ! ZVM_SET_CU=1 zvm env >/dev/null 2>&1; then
|
|
||||||
# zvm env is not available, so we assume all the things are in ZVM_INSTALL
|
|
||||||
state_dir="${ZVM_INSTALL}/.."
|
|
||||||
else
|
|
||||||
state_dir="$(ZVM_SET_CU=1 zvm env |grep -F '"state":' |cut -d: -f2 |cut -d\" -f2)"
|
|
||||||
fi
|
|
||||||
local version="$1"
|
local version="$1"
|
||||||
# This is a bad idea, because it will make a global change
|
# This is a bad idea, because it will make a global change
|
||||||
# zvm use $1
|
# zvm use $1
|
||||||
#
|
if [[ "$(zvm ls | grep "$version")" != "$version" ]]; then
|
||||||
# Check for existence of the version installed in the state directory
|
|
||||||
if [ ! -d "${state_dir}/$version" ]; then
|
|
||||||
log_status "zig/zls version $version not installed - downloading with zvm"
|
|
||||||
local current
|
local current
|
||||||
# zvm 0.7.9 does not indicate which version is in use, so we have to find
|
# zvm 0.7.9 does not indicate which version is in use, so we have to find
|
||||||
# the version that was hard linked into the bin directory
|
# the version that was hard linked into the bin directory
|
||||||
# current="$(find "${ZVM_INSTALL}/.." -samefile "${ZVM_INSTALL}/../bin/zig" | \
|
current="$(find "${ZVM_INSTALL}/.." -samefile "${ZVM_INSTALL}/../bin/zig" | \
|
||||||
# rev | \
|
rev | \
|
||||||
# cut -d/ -f2 | \
|
cut -d/ -f2 | \
|
||||||
# rev)"
|
rev)"
|
||||||
#
|
|
||||||
# We will assume a version of zvm that does allow this
|
|
||||||
current="$(ZVM_SET_CU=1 zvm ls --color off |grep -F ' [x]' |cut -d' ' -f1)"
|
|
||||||
zvm install --zls "$1" # I think this is safe for all except master
|
zvm install --zls "$1" # I think this is safe for all except master
|
||||||
|
|
||||||
# zvm install will automatically use the installed version, which is normally
|
# zvm install will automatically use the installed version, which is normally
|
||||||
# cool, but in this case, we don't want to do that, so we will revert
|
# cool, but in this case, we don't want to do that, so we will revert
|
||||||
zvm use "$current"
|
zvm use "$current"
|
||||||
fi
|
fi
|
||||||
# Don't muck with the path - allow this to be done at the system level
|
PATH_add "${ZVM_INSTALL}/../$1"
|
||||||
PATH_add "${state_dir}/$1"
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue