Skip to content

Instantly share code, notes, and snippets.

@jdx
Created July 12, 2020 00:21
Show Gist options
  • Save jdx/0e493acaa05b7ca49562952185ac54b0 to your computer and use it in GitHub Desktop.
Save jdx/0e493acaa05b7ca49562952185ac54b0 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -euo 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=$4
if [ "$os" == "win" ]; then
url=https://nodejs.org/dist/v$node_version/win-$arch/node.exe
curl -fSsLo "$out" "$url"
else
cd "$(mktemp -d)"
url=https://nodejs.org/dist/v$node_version/$node_base.tar.xz
curl -fSsL "$url" | tar -xJ
mv "$node_base/bin/node" "$out"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment