Skip to content

Commit

Permalink
fix: Install path for hls (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
sestrella authored Jul 4, 2024
1 parent 68d00af commit 6a63dc0
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 13 deletions.
11 changes: 9 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,26 @@ jobs:
- ubuntu-latest
test:
- plugin: cabal
version: latest
command: cabal --version
- plugin: ghc
version: latest
command: ghc --version
- plugin: hls
version: latest
command: haskell-language-server-wrapper --version
- plugin: hls
version: 1.6.1.0
command: haskell-language-server-wrapper --version
- plugin: stack
version: latest
command: stack --version
fail-fast: true
runs-on: ${{ matrix.os }}
needs: [check]
steps:
- uses: asdf-vm/actions/plugin-test@v3
with:
command: ${{ matrix.test.command || format('{0} --version', matrix.test.plugin) }}
plugin: ${{ matrix.test.plugin }}
version: ${{ matrix.test.version || 'latest' }}
version: ${{ matrix.test.version }}
command: ${{ matrix.test.command }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.devenv
.direnv
.ghcup
.pre-commit-config.yaml
23 changes: 12 additions & 11 deletions lib/utils.bash
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,26 @@ ensure_ghcup() {
fi
}

list_all_versions() {
ghcup_wrapper() {
ensure_ghcup
"$(ghcup_bin_dir)/ghcup" list -t "$1" -r | awk '{printf $2" "}'
GHCUP_INSTALL_BASE_PREFIX="$(asdf_plugin_path)" "$(ghcup_bin_dir)/ghcup" "$@"
}

ver() {
echo "$1" | awk -F . '{ printf("%02d%02d", $1,$2); }'
list_all_versions() {
ghcup_wrapper list -t "$1" -r | awk '{printf $2 " "}'
}

install_version() {
local tool="$1"
local version="$2"
local path="$3"
local tool version path version_prefix

ensure_ghcup
tool="$1"
version="$2"
path="$3"
version_prefix=$(echo "$version" | awk -F '.' '{print $1 "." $2}')

if [[ $tool == "ghc" ]] || { [[ $tool == "hls" ]] && [[ $(ver "$version") -ge $(ver "1.7") ]]; }; then
GHCUP_INSTALL_BASE_PREFIX="$(asdf_plugin_path)" "$(ghcup_bin_dir)/ghcup" install "$tool" "$version" -i "$path"
if [[ $tool == "ghc" ]] || { [[ $tool == "hls" ]] && [[ $(echo "$version_prefix >= 1.7" | bc) -eq 1 ]]; }; then
ghcup_wrapper install "$tool" "$version" -i "$path"
else
GHCUP_INSTALL_BASE_PREFIX="$(asdf_plugin_path)" "$(ghcup_bin_dir)/ghcup" install "$tool" "$version" -i "${path}/bin"
ghcup_wrapper install "$tool" "$version" -i "${path}/bin"
fi
}

0 comments on commit 6a63dc0

Please sign in to comment.