Skip to content

Commit 6cb5881

Browse files
committed
add support for asdf 0.16
1 parent 6e0d663 commit 6cb5881

File tree

2 files changed

+88
-76
lines changed

2 files changed

+88
-76
lines changed

scripts/launch.fish

Lines changed: 46 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -6,50 +6,55 @@
66
# code simplicity instead of performance. Hence some potentially redundant
77
# moves here.
88

9-
# First order of business, see whether we can setup asdf-vm
10-
11-
set asdf_dir $ASDF_DIR
12-
13-
test -z "$asdf_dir"; and set asdf_dir "$HOME/.asdf"
14-
15-
set asdf_vm "$asdf_dir/asdf.fish"
16-
17-
echo "Looking for ASDF install" >&2
18-
19-
if test -f "$asdf_vm"
20-
echo "ASDF install found in $asdf_vm, sourcing" >&2
21-
source "$asdf_vm"
9+
# First order of business, see whether we can setup asdf
10+
11+
echo "Looking for asdf install" >&2
12+
set ASDF_DIR (or $ASDF_DIR (set -q HOME; echo $HOME)/.asdf)
13+
14+
# Check if we have the asdf binary for version >= 0.16.0
15+
set asdf (which asdf)
16+
if test -n "$asdf"
17+
echo "asdf executable found at $asdf. Setting ASDF_DIR=${ASDF_DIR} and adding ${ASDF_DATA_DIR}/shims to PATH." >&2
18+
# If the binary is found, set up environment for newer asdf versions
19+
set -gx ASDF_DATA_DIR "$ASDF_DIR"
20+
set -gx PATH "$ASDF_DATA_DIR/shims" $PATH
2221
else
23-
echo "ASDF not found" >&2
24-
echo "Looking for mise executable" >&2
25-
26-
set mise (which mise)
27-
if test -n "$mise"
28-
echo "mise executable found in $mise, activating" >&2
29-
30-
"$mise" env -s fish | source
31-
else
32-
echo "mise not found" >&2
33-
echo "Looking for rtx executable" >&2
34-
35-
set rtx (which rtx)
36-
if test -n "$rtx"
37-
echo "rtx executable found in $rtx, activating" >&2
38-
39-
"$rtx" env -s fish | source
22+
# Fallback to old method for asdf version <= 0.15.x
23+
set ASDF_SH "$ASDF_DIR/asdf.fish"
24+
if test -f "$ASDF_SH"
25+
echo "Legacy pre v0.16.0 asdf install found at $ASDF_SH, sourcing" >&2
26+
# Source the old asdf.sh script for versions <= 0.15.0
27+
source "$ASDF_SH"
4028
else
41-
echo "rtx not found" >&2
42-
43-
set vfox (which vfox)
44-
if test -n "$vfox"
45-
echo "vfox executable found in $vfox, activating" >&2
46-
47-
"$vfox" activate fish | source
48-
else
49-
echo "vfox not found" >&2
50-
end
29+
echo "asdf not found" >&2
30+
echo "Looking for mise executable" >&2
31+
32+
set mise (which mise)
33+
if test -n "$mise"
34+
echo "mise executable found at $mise, activating" >&2
35+
source ( "$mise" env -s fish )
36+
else
37+
echo "mise not found" >&2
38+
echo "Looking for rtx executable" >&2
39+
40+
set rtx (which rtx)
41+
if test -n "$rtx"
42+
echo "rtx executable found at $rtx, activating" >&2
43+
source ( "$rtx" env -s fish )
44+
else
45+
echo "rtx not found" >&2
46+
echo "Looking for vfox executable" >&2
47+
48+
set vfox (which vfox)
49+
if test -n "$vfox"
50+
echo "vfox executable found at $vfox, activating" >&2
51+
source ( "$vfox" activate fish )
52+
else
53+
echo "vfox not found" >&2
54+
end
55+
end
56+
end
5157
end
52-
end
5358
end
5459

5560
# In case that people want to tweak the path, which Elixir to use, or

scripts/launch.sh

Lines changed: 42 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
# code simplicity instead of performance. Hence some potentially redundant
77
# moves here.
88

9-
# First order of business, see whether we can setup asdf-vm
109

1110
did_relaunch=$1
1211

@@ -36,45 +35,53 @@ case "${did_relaunch}" in
3635
;;
3736
esac
3837

38+
# First order of business, see whether we can setup asdf
39+
echo "Looking for asdf install" >&2
3940
ASDF_DIR=${ASDF_DIR:-"${HOME}/.asdf"}
4041

41-
asdf_vm="${ASDF_DIR}/asdf.sh"
42-
43-
>&2 echo "Looking for ASDF install"
44-
if test -f "${asdf_vm}"
45-
then
46-
>&2 echo "ASDF install found in $asdf_vm, sourcing"
47-
# shellcheck disable=SC1090
48-
. "${asdf_vm}"
42+
# Check if we have the asdf binary for version >= 0.16.0
43+
if command -v asdf >/dev/null 2>&1; then
44+
>&2 echo "asdf executable found at $(command -v asdf). Setting ASDF_DIR=${ASDF_DIR} and adding ${ASDF_DATA_DIR}/shims to PATH."
45+
# If the binary is found, set up environment for newer asdf versions
46+
export ASDF_DATA_DIR="$ASDF_DIR"
47+
export PATH="$ASDF_DATA_DIR/shims:$PATH"
4948
else
50-
>&2 echo "ASDF not found"
51-
>&2 echo "Looking for mise executable"
52-
53-
if which mise >/dev/null
54-
then
55-
>&2 echo "mise executable found in $(which mise), activating"
56-
eval "$($(which mise) env -s "$preferred_shell")"
57-
else
58-
>&2 echo "mise not found"
59-
>&2 echo "Looking for rtx executable"
60-
61-
if which rtx >/dev/null
62-
then
63-
>&2 echo "rtx executable found in $(which rtx), activating"
64-
eval "$($(which rtx) env -s "$preferred_shell")"
49+
# Fallback to old method for version <= 0.15.x
50+
ASDF_SH="${ASDF_DIR}/asdf.sh" # Path to the old shell script for version <= 0.15.x
51+
if test -f "$ASDF_SH"; then
52+
>&2 echo "Legacy pre v0.16.0 asdf install found at $ASDF_SH, sourcing"
53+
# Source the old asdf.sh script for versions <= 0.15.0
54+
. "$ASDF_SH"
6555
else
66-
>&2 echo "rtx not found"
67-
68-
>&2 echo "Looking for vfox executable"
69-
if which vfox >/dev/null
70-
then
71-
>&2 echo "vfox executable found in $(which vfox), activating"
72-
eval "$($(which vfox) activate "$preferred_shell")"
73-
else
74-
>&2 echo "vfox not found"
75-
fi
56+
>&2 echo "asdf not found"
57+
>&2 echo "Looking for mise executable"
58+
59+
# Look for mise executable
60+
if command -v mise >/dev/null 2>&1; then
61+
>&2 echo "mise executable found at $(command -v mise), activating"
62+
eval "$($(command -v mise) env -s "$preferred_shell")"
63+
else
64+
>&2 echo "mise not found"
65+
>&2 echo "Looking for rtx executable"
66+
67+
# Look for rtx executable
68+
if command -v rtx >/dev/null 2>&1; then
69+
>&2 echo "rtx executable found at $(command -v rtx), activating"
70+
eval "$($(command -v rtx) env -s "$preferred_shell")"
71+
else
72+
>&2 echo "rtx not found"
73+
>&2 echo "Looking for vfox executable"
74+
75+
# Look for vfox executable
76+
if command -v vfox >/dev/null 2>&1; then
77+
>&2 echo "vfox executable found at $(command -v vfox), activating"
78+
eval "$($(command -v vfox) activate "$preferred_shell")"
79+
else
80+
>&2 echo "vfox not found"
81+
fi
82+
fi
83+
fi
7684
fi
77-
fi
7885
fi
7986

8087
# In case that people want to tweak the path, which Elixir to use, or

0 commit comments

Comments
 (0)