summaryrefslogtreecommitdiff
path: root/tools/update-npm.sh
blob: c106570d0b33ddc84f4adc32cd24fd41b8fc949f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/sh
set -e
# Shell script to update npm in the source tree to a specific version

BASE_DIR="$( pwd )"/
DEPS_DIR="$BASE_DIR"deps/
NPM_VERSION=$1

if [ "$#" -le 0 ]; then
  echo "Error: please provide an npm version to update to"
  exit 1
fi

WORKSPACE="$TMPDIR"update-npm-$NPM_VERSION/

if [ -d "$WORKSPACE" ]; then
  echo "Cleaning up old workspace"
  rm -rf "$WORKSPACE"
fi

echo "Making temporary workspace"

mkdir -p "$WORKSPACE"

cd "$WORKSPACE"

git clone git@github.com:npm/cli.git
cd cli

echo "Preparing npm release"

git checkout v"$NPM_VERSION"
make
make release

echo "Removing old npm"

cd "$DEPS_DIR"
rm -rf npm/

echo "Copying new npm"

tar zxf "$WORKSPACE"cli/release/npm-"$NPM_VERSION".tgz

echo "Deleting temporary workspace"

rm -rf "$WORKSPACE"

echo ""
echo "All done!"
echo ""
echo "Please git add npm, commit the new version, and whitespace-fix:"
echo ""
echo "$ git add -A deps/npm"
echo "$ git commit -m \"deps: upgrade npm to $NPM_VERSION\""
echo "$ git rebase --whitespace=fix master"
echo ""