diff options
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/install.sh | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/scripts/install.sh b/scripts/install.sh index a8425fa7d..43f8f5157 100644 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -1,19 +1,37 @@ -#!/bin/sh -r=${RANDOM-$(date +%s)} +#!/bin/bash TMP=$(mktemp -dt npm.XXXXXX) -if [ "x$TMP" == "x" ]; then - TMP=$PWD/npm-$r - mkdir -- "$TMP" || (echo "failed to mkdir $TMP" >&2 ; exit 1) +if [ -n "$TMP" ]; then + TMP=$PWD/npm-install-please-remove-this + rm -rf -- $TMP || true + mkdir -- "$TMP" + if [ $? -ne 0 ]; then + echo "failed to mkdir $TMP" >&2 + exit 1 + fi fi BACK="$PWD" -tar=${TAR-$(if which gtar 1>/dev/null 2>/dev/null; then echo "gtar" ; else echo "tar" ; fi)} -egrep=$(if which gegrep 1>/dev/null 2>/dev/null; then echo "gegrep" ; else echo "egrep" ; fi) +tar=${TAR} +if [ -n "$tar" ]; then + if which gtar 1>/dev/null 2>/dev/null; then + tar=gtar + else + tar=tar + fi +fi + +if which gegrep 1>/dev/null 2>/dev/null; then + egrep="gegrep" +else + egrep="egrep" +fi + cd -- "$TMP" \ && curl -L $( curl http://registry.npmjs.org/npm/latest \ | $egrep -o 'tarball":"[^"]+' \ | $egrep -o 'http://.*' - ) | $tar -xzf - --strip-components=1 \ + ) | $tar -xzf - \ + && cd * \ && make uninstall install \ && cd -- "$BACK" \ && rm -rf -- "$TMP" \ |