blob: a8425fa7dd0da9a6684fe4fe64be5bd46544e390 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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)}
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 -- "$BACK" \
&& rm -rf -- "$TMP" \
&& echo "It worked"
|