Last active
July 5, 2016 05:48
-
-
Save bencooling/ef15845e8b06cade75d9507a5f57cb32 to your computer and use it in GitHub Desktop.
download-node-nightly.sh - simple script to fetch Node.js nightlies on OS X and Linux (x86, x64 & ARM)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Usage: | |
# sh download-node-nightly.sh | |
hasxz=$(which xzcat) | |
os=$(uname | tr '[A-Z]' '[a-z]') | |
arch=$(uname -m) | |
pwd=$(PWD) | |
[[ "$arch" == "x86_64" ]] && arch=x64 | |
[[ "$arch" == "x686" ]] && arch=x32 | |
type=nightly | |
echo -e "Getting latest list of nightlies…\n" | |
latest=$(curl -sL https://nodejs.org/download/${type}/index.tab | head -2 | tail -1 | awk '{ print $1 }') | |
echo -e "Downloading…\n\n" | |
url="https://nodejs.org/download/${type}/$latest/node-${latest}-${os}-x64.tar" | |
if [ "X${hasxz}" == "X" ]; then | |
url="${url}.gz" | |
pipecmd="| tar -zx -C ./" | |
else | |
url="${url}.xz" | |
pipecmd="| xzcat | tar -x -C ./" | |
fi | |
sh -c "curl -L --progress-bar '${auth}' '${url}' ${pipecmd}" | |
sh -c "mv ${pwd}/node-${latest}-${os}-x64/ /usr/local/bin/node" | |
echo "node-${latest}-${os}-x64 now available as node binary in path" | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment