Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2010-12-21 22:08:36 +0300
committerisaacs <i@izs.me>2010-12-21 22:08:36 +0300
commitee393f89a9b96820867a87a66ac9318777d151c7 (patch)
treed46e1596079eda8da2569872eeba3b0ae16296b5 /scripts
parent7c5b05da1055cefe7b8014c6bb901ac3a8e72687 (diff)
Portability.
God DAMN I hate writing sh. Bash is SO much nicer.
Diffstat (limited to 'scripts')
-rwxr-xr-x[-rw-r--r--]scripts/install.sh61
1 files changed, 37 insertions, 24 deletions
diff --git a/scripts/install.sh b/scripts/install.sh
index ca7d7491e..0b0737f57 100644..100755
--- a/scripts/install.sh
+++ b/scripts/install.sh
@@ -1,38 +1,51 @@
-#!/bin/bash
-TMP=$(mktemp -dt npm.XXXXXX)
-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
+#!/bin/sh
+
+TMP="${TMPDIR}"
+if [ "x$TMP" = "x" ]; then
+ TMP="/tmp"
fi
+TMP="${TMP}/npm.$$"
+rm -rf "$TMP" || true
+mkdir "$TMP"
+if [ $? -ne 0 ]; then
+ echo "failed to mkdir $TMP" >&2
+ exit 1
+fi
+
BACK="$PWD"
tar="${TAR}"
if [ -z "$tar" ]; then
- if which gtar 1>/dev/null 2>/dev/null; then
- tar=gtar
- else
+ # sniff for gtar/gegrep
+ # use which, but don't trust it very much.
+ tar=`which gtar 2>&1`
+ if [ $? -ne 0 ] || ! [ -x $tar ]; then
tar=tar
fi
fi
-if which gegrep 1>/dev/null 2>/dev/null; then
- egrep="gegrep"
-else
- egrep="egrep"
+egrep=`which gegrep 2>&1`
+if [ $? -ne 0 ] || ! [ -x $egrep ]; then
+ egrep=egrep
fi
-cd -- "$TMP" \
- && curl -L $(
- curl http://registry.npmjs.org/npm/latest \
+url=`curl http://registry.npmjs.org/npm/latest \
| $egrep -o 'tarball":"[^"]+' \
- | $egrep -o 'http://.*'
- ) | $tar -xzf - \
+ | $egrep -o 'http://.*'`
+ret=$?
+if [ $ret -ne 0 ]; then
+ echo "Failed to get tarball url" >&2
+ exit $ret
+fi
+
+cd "$TMP" \
+ && curl -L "$url" | $tar -xzf - \
&& cd * \
&& make uninstall install \
- && cd -- "$BACK" \
- && rm -rf -- "$TMP" \
+ && cd "$BACK" \
+ && rm -rf "$TMP" \
&& echo "It worked"
+ret=$?
+if [ $ret -ne 0 ]; then
+ echo "It failed" >&2
+fi
+exit $ret