From 52bdbe9f9620fd95bcb5b166d5f8712ce37a5e9c Mon Sep 17 00:00:00 2001 From: Buddy Sandidge Date: Mon, 5 Jul 2021 22:23:44 -0700 Subject: [PATCH] Add home node install script --- node/.local/bin/install-node-home | 38 +++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100755 node/.local/bin/install-node-home diff --git a/node/.local/bin/install-node-home b/node/.local/bin/install-node-home new file mode 100755 index 0000000..982ea98 --- /dev/null +++ b/node/.local/bin/install-node-home @@ -0,0 +1,38 @@ +#!/usr/bin/env bash + +set -e + +# shellcheck disable=SC1090 +source "${XDG_DATA_HOME}/buddy-up/includes/utils.sh" + +get_arch () { + case $(uname -m) in + x86_64*) echo x64;; + amd64*) echo x64;; + arm) echo armv7l;; + armv7*) echo armv7l;; + armv6*) echo armv7l;; + armv8*) echo arm64;; + aarch64*) echo arm64;; + *) >&2 echo "unsupported architecture: $(uname -m)"; exit 1;; + esac +} + +APPS="node npm npx" +VERSION=${VERSION:-v14.17.3} +DEST="${XDG_DATA_HOME}/apps/releases/node" +URL=https://nodejs.org/dist/${VERSION}/node-${VERSION}-$(get_os)-$(get_arch).tar.xz + +extract_tarball "${URL}" "${DEST}/${VERSION}" "--strip-components 1" +set_current_link "${DEST}" "${VERSION}" + +pushd "${XDG_BIN_HOME}" >/dev/null +for app in ${APPS}; do + if [[ -L "${XDG_BIN_HOME}/${app}" ]]; then + unlink "${XDG_BIN_HOME}/${app}" + fi + + REL_LINK="$(relative_path "${XDG_BIN_HOME}" "${DEST}/current/bin/${app}")" + ln --symbolic "${REL_LINK}" "${app}" +done +popd >/dev/null