Update node install scripts

main
Buddy Sandidge 2 years ago
parent 18246be28e
commit 8ce19953de

@ -5,7 +5,7 @@ set -euo pipefail
# shellcheck disable=SC1090 # shellcheck disable=SC1090
source "${XDG_DATA_HOME}/buddy-up/includes/node.sh" source "${XDG_DATA_HOME}/buddy-up/includes/node.sh"
VERSION=${VERSION:-node_lts} VERSION=${VERSION:-$(node_lts)}
DEST=${XDG_DATA_HOME}/apps/releases/node DEST=${XDG_DATA_HOME}/apps/releases/node
CURRENT=${DEST}/current CURRENT=${DEST}/current
@ -15,7 +15,7 @@ URL=https://nodejs.org/dist/${VERSION}/node-${VERSION}-$(get_os)-$(get_arch).tar
extract_tarball "${URL}" "${DEST}/${VERSION}" "--strip-components 1" extract_tarball "${URL}" "${DEST}/${VERSION}" "--strip-components 1"
set_current_link "${DEST}" "${VERSION}" set_current_link "${DEST}" "${VERSION}"
APPS=$(find "${CURRENT}"/bin -not -type d -exec basename {} ';') APPS=$(find "${DEST}/${VERSION}/bin" -not -type d -exec basename {} ';')
for app in ${APPS}; do for app in ${APPS}; do
set_symlink "${CURRENT}/bin/${app}" "${XDG_BIN_HOME}/${app}" set_symlink "${CURRENT}/bin/${app}" "${XDG_BIN_HOME}/${app}"
done done

@ -5,9 +5,10 @@ set -e
# shellcheck disable=SC1090 # shellcheck disable=SC1090
source "${XDG_DATA_HOME}/buddy-up/includes/node.sh" source "${XDG_DATA_HOME}/buddy-up/includes/node.sh"
VERSION=${VERSION:-$(node_lts)}
PREFIX=${PREFIX:-/usr/local} PREFIX=${PREFIX:-/usr/local}
DEST="${PREFIX}/apps/releases/node" DEST=${PREFIX}/apps/releases/node
CURRENT="${DEST}/current" CURRENT=${DEST}/current
# shellcheck disable=SC2034 # shellcheck disable=SC2034
URL=https://nodejs.org/dist/${VERSION}/node-${VERSION}-$(get_os)-$(get_arch).tar.xz URL=https://nodejs.org/dist/${VERSION}/node-${VERSION}-$(get_os)-$(get_arch).tar.xz
@ -15,7 +16,7 @@ URL=https://nodejs.org/dist/${VERSION}/node-${VERSION}-$(get_os)-$(get_arch).tar
extract_tarball "${URL}" "${DEST}/${VERSION}" "--strip-components 1" sudo extract_tarball "${URL}" "${DEST}/${VERSION}" "--strip-components 1" sudo
set_current_link "${DEST}" "${VERSION}" sudo set_current_link "${DEST}" "${VERSION}" sudo
APPS=$(find "${CURRENT}"/bin -not -type d -exec basename {} ';') APPS=$(find "${DEST}/${VERSION}/bin" -not -type d -exec basename {} ';')
for app in ${APPS}; do for app in ${APPS}; do
set_symlink "${CURRENT}/bin/${app}" "${PREFIX}/bin/${app}" sudo set_symlink "${CURRENT}/bin/${app}" "${PREFIX}/bin/${app}" sudo
done done

@ -4,6 +4,12 @@
source "${XDG_DATA_HOME}/buddy-up/includes/utils.sh" source "${XDG_DATA_HOME}/buddy-up/includes/utils.sh"
node_lts () ( node_lts () (
curl --silent https://nodejs.org/dist/index.tab |
cut -f 1,10 | grep -v '-' | head -n 2 | tail -n 1 | cut -f 1
)
node_current () (
curl --silent https://nodejs.org/dist/index.tab | curl --silent https://nodejs.org/dist/index.tab |
cut -f 1,10 | grep '-' | head -n 1 | cut -f 1 cut -f 1,10 | grep '-' | head -n 1 | cut -f 1
) )

Loading…
Cancel
Save