Implement download_node and download_npm bash scripts

This commit is contained in:
Juan Cruz Viotti 2015-02-11 12:33:25 -04:00
parent d97a4d9d49
commit 790ec86d51
2 changed files with 56 additions and 0 deletions

34
scripts/download_node.sh Executable file
View File

@ -0,0 +1,34 @@
#!/bin/bash
# Example:
# $ ./download_node darwin x64 v0.12.0 ../bin/node
OS=$1
ARCH=$2
NODE_VERSION=$3
OUTPUT=$4
if [ -z $OS ] || [ -z $ARCH ] || [ -z $NODE_VERSION ] || [ -z $OUTPUT ]; then
echo "Usage: $0 <os> <arch> <node_version> <output>"
exit 1
fi
NODE_DIST_URL="http://nodejs.org/dist"
CURL="curl -#"
PACKAGE="node-$NODE_VERSION-$OS-$ARCH"
echo ""
echo "Downloading $PACKAGE"
echo ""
if [ "$OS" == "win32" ]; then
if [ "$arch" == "x86" ]; then
$CURL $NODE_DIST_URL/$NODE_VERSION/node.exe -o $OUTPUT/$PACKAGE.exe
else
$CURL $NODE_DIST_URL/$NODE_VERSION/$ARCH/node.exe -o $OUTPUT/$PACKAGE.exe
fi
else
$CURL $NODE_DIST_URL/$NODE_VERSION/$PACKAGE.tar.gz | tar xz -C $OUTPUT/
cp $OUTPUT/$PACKAGE/bin/node $OUTPUT/$PACKAGE.bin
rm -rf $OUTPUT/$PACKAGE
fi

22
scripts/download_npm.sh Executable file
View File

@ -0,0 +1,22 @@
#!/bin/bash
# Example:
# $ ./download_npm v2.5.1 ./bin/npm
NPM_VERSION=$1
OUTPUT=$2
if [ -z $NPM_VERSION ] || [ -z $OUTPUT ]; then
echo "Usage: $0 <npm_version> <output_directory>"
exit 1
fi
echo ""
echo "Downloading npm@$NPM_VERSION"
echo ""
mkdir -p $OUTPUT
# http://stackoverflow.com/questions/11497457/git-clone-without-git-directory
git clone --depth=1 --branch $NPM_VERSION --single-branch git@github.com:npm/npm.git $OUTPUT
rm -rf $OUTPUT/.git