# Template file for 'bash-language-server'
pkgname=bash-language-server
version=5.6.0
revision=1
hostmakedepends="pnpm"
depends="nodejs"
short_desc="Bash language server"
maintainer="Orphaned <orphan@voidlinux.org>"
license="MIT"
homepage="https://github.com/bash-lsp/bash-language-server"
distfiles="https://github.com/bash-lsp/bash-language-server/archive/refs/tags/server-${version}.tar.gz"
checksum=54025af2243bcb7a08300662ad919847c084abfa1913dee2151b2ff7ca0cf8c9

do_build() {
	pnpm install --frozen-lockfile
	pnpm run compile
}

do_install() {
	TARGET_PATH="usr/lib/${pkgname}"
	cd server

	rm -r node_modules
	npm install --omit=dev

	vmkdir ${TARGET_PATH}
	vcopy node_modules ${TARGET_PATH}
	vcopy out ${TARGET_PATH}
	vcopy package.json ${TARGET_PATH}
	vcopy tree-sitter-bash.wasm ${TARGET_PATH}

	vmkdir usr/bin
	ln -sf /${TARGET_PATH}/out/cli.js ${DESTDIR}/usr/bin/${pkgname}
	chmod 0755 ${DESTDIR}/${TARGET_PATH}/out/cli.js

	vlicense ../LICENSE
}
