Skip to content

Commit 5e4c59d

Browse files
authored
fix: install specific version or latest version of bun and global packages (#5)
this changeset is to fix the issues related to installing latest version of bun and resolve exe path to install global packages.
1 parent d8f42c8 commit 5e4c59d

File tree

2 files changed

+14
-18
lines changed

2 files changed

+14
-18
lines changed

src/deno/devcontainer-feature.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"denoland.vscode-deno"
2626
],
2727
"settings": {
28+
"deno.enable": true,
2829
"github.copilot.chat.codeGeneration.instructions": [
2930
{
3031
"text": "This dev container includes `deno` pre-installed and available on the `PATH` for Deno, JavaScript and Typescript development."

src/deno/install.sh

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -42,33 +42,28 @@ check_packages ca-certificates curl dirmngr gpg gpg-agent
4242

4343
# Normalize version tag format
4444
case "${VERSION}" in
45-
latest | v*)
46-
TAG="$VERSION"
47-
;;
48-
*)
49-
TAG="v${VERSION}"
50-
;;
45+
latest) TAG="$(curl -s https://dl.deno.land/release-latest.txt)" ;;
46+
v*) TAG="${VERSION}" ;;
47+
*) TAG="v${VERSION}" ;;
5148
esac
5249

5350
# Run installer as non-root user
5451
# If we don't already have Deno installed, install it now.
55-
if ! deno --version > /dev/null ; then
56-
echo "Installing Deno..."
57-
if [ "${DENO_VERSION}" = "latest" ]; then
58-
curl -fsSL https://deno.land/install.sh | sh
59-
else
60-
curl -fsSL https://deno.land/install.sh | sh -s ${TAG}
61-
fi
52+
if ! deno --version > /dev/null; then
53+
echo "Installing Deno ${TAG}..."
54+
su "${_REMOTE_USER}" -c "curl -fsSL https://deno.land/install.sh | sh -s -- --yes ${TAG}"
6255
fi
6356

57+
INSTALL_ENV=DENO_INSTALL
58+
INSTALL_DIR="${!INSTALL_ENV:-${_REMOTE_USER_HOME}/.deno}"
59+
BIN_DIR="${INSTALL_DIR}/bin"
60+
EXE="${BIN_DIR}/deno"
61+
6462
# Install global packages if specified
65-
# See # See https://docs.deno.com/runtime/reference/cli/install/#global-installation
63+
# See https://docs.deno.com/runtime/reference/cli/install/#global-installation
6664
if [ "${#PACKAGES[@]}" -gt 0 ]; then
6765
echo "Installing global packages..."
68-
su "${_REMOTE_USER}" -c "${EXE} install --global --allow-net --allow-read ${PACKAGES}"
66+
su "${_REMOTE_USER}" -c "$EXE install --global --allow-net --allow-read ${PACKAGES}"
6967
fi
7068

71-
# Clean up installer
72-
rm -rf "${INSTALLER}"
73-
7469
echo "Done!"

0 commit comments

Comments
 (0)