Skip to content

Instantly share code, notes, and snippets.

@jdx
Created July 12, 2020 00:21
Show Gist options
  • Save jdx/cdef44190c0425b6218556fa7c16cd64 to your computer and use it in GitHub Desktop.
Save jdx/cdef44190c0425b6218556fa7c16cd64 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -euxo pipefail
# Downloads a node tarball from https://nodejs.org/dist/ and extracts just
# the binary into the current directory. Chiefly we use this to get a node
# binary for uploading to manifold.
if [[ $# -ne 4 ]]; then
echo "USAGE: $0 <node_version> <os> <arch> <filename>"
exit 1
fi
node_version=$1
os=$2
arch=$3
node_base="node-v$node_version-$os-$arch"
out=$(realpath "$4")
cd "$(mktemp -d)"
if [ "$os" == "win" ]; then
url=https://nodejs.org/dist/v$node_version/$node_base.7z
curl -fSsLo "$node_base.7z" "$url"
7z x "$node_base.7z"
tar -cJf "$out" "$node_base"
else
url=https://nodejs.org/dist/v$node_version/$node_base.tar.xz
curl -fSsL "$url" > "$out"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment