• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/sh
2set -e
3# Shell script to update npm in the source tree to a specific version
4
5BASE_DIR="$( pwd )"/
6DEPS_DIR="$BASE_DIR"deps/
7NPM_VERSION=$1
8
9if [ "$#" -le 0 ]; then
10  echo "Error: please provide an npm version to update to"
11  exit 1
12fi
13
14echo "Making temporary workspace"
15
16WORKSPACE=$(mktemp -d 2> /dev/null || mktemp -d -t 'tmp')
17
18cleanup () {
19  EXIT_CODE=$?
20  [ -d "$WORKSPACE" ] && rm -rf "$WORKSPACE"
21  exit $EXIT_CODE
22}
23
24trap cleanup INT TERM EXIT
25
26cd "$WORKSPACE"
27
28git clone --depth=1 --branch="v$NPM_VERSION" git@github.com:npm/cli.git
29cd cli
30
31echo "Preparing npm release"
32
33make
34make release
35
36echo "Removing old npm"
37
38cd "$DEPS_DIR"
39rm -rf npm/
40
41echo "Copying new npm"
42
43tar zxf "$WORKSPACE"/cli/release/npm-"$NPM_VERSION".tgz
44
45echo ""
46echo "All done!"
47echo ""
48echo "Please git add npm, commit the new version, and whitespace-fix:"
49echo ""
50echo "$ git add -A deps/npm"
51echo "$ git commit -m \"deps: upgrade npm to $NPM_VERSION\""
52echo "$ git rebase --whitespace=fix master"
53echo ""
54