diff options
author | isaacs <i@izs.me> | 2011-04-30 23:59:38 +0400 |
---|---|---|
committer | isaacs <i@izs.me> | 2011-05-01 00:20:33 +0400 |
commit | 7f6728c19c596dac997724323c6bef7f542e7dfe (patch) | |
tree | 87591e713a99acb4e9c922c9d1a3565f16918c8e /scripts | |
parent | 8542b72b1e3ccf5e30c3b8a66f185afe35a38473 (diff) |
Clean up 0.x if installing 1.0
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/install.sh | 40 |
1 files changed, 36 insertions, 4 deletions
diff --git a/scripts/install.sh b/scripts/install.sh index 8dbf9acf2..ffdbe9340 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -4,15 +4,21 @@ if ! [ "x$NPM_DEBUG" = "x" ]; then set +x fi - +# make sure that node exists node=`which node 2>&1` ret=$? if [ $ret -ne 0 ] || ! [ -x $node ]; then echo "npm cannot be installed without nodejs." >&2 echo "Install node first, and then try again." >&2 + echo "" >&2 + echo "Maybe node is installed, but not in the PATH?" >&2 + echo "Note that running as sudo can change envs." >&2 + echo "" + echo "PATH=$PATH" >&2 exit $ret fi +# set the temp dir TMP="${TMPDIR}" if [ "x$TMP" = "x" ]; then TMP="/tmp" @@ -74,11 +80,12 @@ cd "$TMP" \ if [ $ret -eq 0 ]; then req=`$node bin/read-package-json.js package.json engines.node` if [ -e node_modules ]; then - $node node_modules/semver/bin/semver -v "$node_version" -r "$req" + $node node_modules/semver/bin/semver -v "$node_version" -r "$req" + ret=$? else - $node bin/semver.js -v "$node_version" -r "$req" + $node bin/semver.js -v "$node_version" -r "$req" + ret=$? fi - ret=$? fi if [ $ret -ne 0 ]; then echo "You need node $req to run this program." >&2 @@ -86,6 +93,31 @@ cd "$TMP" \ echo "Please upgrade node before continuing." exit $ret fi) \ + && (ver=`$node bin/read-package-json.js package.json version` + isnpm10=0 + if [ $ret -eq 0 ]; then + req=`$node bin/read-package-json.js package.json engines.node` + if [ -e node_modules ]; then + if $node node_modules/semver/bin/semver -v "$ver" -r "1" + then + isnpm10=1 + fi + else + if $node bin/semver -v "$ver" -r ">=1.0"; then + isnpm10=1 + fi + fi + fi + + ret=0 + if [ $isnpm10 -eq 1 ] && [ -f "scripts/clean-old.sh" ]; then + NODE=$node /bin/sh "scripts/clean-old.sh" + ret=$? + fi + if [ $ret -ne 0 ]; then + echo "Aborted 0.x cleanup. Exiting." >&2 + exit $ret + fi) \ && (if [ "$make" = "NOMAKE" ] || ! $make clean install; then $node cli.js cache clean $node cli.js rm npm --force --global |