From 1f46fb8443dcf627ed18938b57c349eebb638cde Mon Sep 17 00:00:00 2001 From: isaacs Date: Sat, 20 Nov 2010 17:35:19 -0800 Subject: More portable install script. --- scripts/install.sh | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) mode change 100755 => 100644 scripts/install.sh (limited to 'scripts') diff --git a/scripts/install.sh b/scripts/install.sh old mode 100755 new mode 100644 index 9ad05843f..a8425fa7d --- a/scripts/install.sh +++ b/scripts/install.sh @@ -1,10 +1,20 @@ #!/bin/sh r=${RANDOM-$(date +%s)} +TMP=$(mktemp -dt npm.XXXXXX) +if [ "x$TMP" == "x" ]; then + TMP=$PWD/npm-$r + mkdir -- "$TMP" || (echo "failed to mkdir $TMP" >&2 ; exit 1) +fi +BACK="$PWD" tar=${TAR-$(if which gtar 1>/dev/null 2>/dev/null; then echo "gtar" ; else echo "tar" ; fi)} -mkdir npm-$r \ - && cd npm-$r \ - && curl -L http://github.com/isaacs/npm/tarball/master | $tar xzf - --strip-components=1 \ +egrep=$(if which gegrep 1>/dev/null 2>/dev/null; then echo "gegrep" ; else echo "egrep" ; fi) +cd -- "$TMP" \ + && curl -L $( + curl http://registry.npmjs.org/npm/latest \ + | $egrep -o 'tarball":"[^"]+' \ + | $egrep -o 'http://.*' + ) | $tar -xzf - --strip-components=1 \ && make uninstall install \ - && cd .. \ - && rm -rf npm-$r \ + && cd -- "$BACK" \ + && rm -rf -- "$TMP" \ && echo "It worked" -- cgit v1.2.3