| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,8 +2,13 @@ | |||
| 2 | 2 | set -e | |
| 3 | 3 | # Shell script to update npm in the source tree to a specific version | |
| 4 | 4 | ||
| 5 | - BASE_DIR=$(cd "$(dirname "$0")/.." && pwd) | ||
| 5 | + BASE_DIR=$(cd "$(dirname "$0")/../.." && pwd) | ||
| 6 | 6 | DEPS_DIR="$BASE_DIR/deps" | |
| 7 | + [ -z "$NODE" ] && NODE="$BASE_DIR/out/Release/node" | ||
| 8 | + [ -x "$NODE" ] || NODE=$(command -v node) | ||
| 9 | + | ||
| 10 | + NPM="$DEPS_DIR/npm/bin/npm-cli.js" | ||
| 11 | + | ||
| 7 | 12 | NPM_VERSION=$1 | |
| 8 | 13 | ||
| 9 | 14 | if [ "$#" -le 0 ]; then | |
@@ -25,22 +30,17 @@ trap cleanup INT TERM EXIT | |||
| 25 | 30 | ||
| 26 | 31 | cd "$WORKSPACE" | |
| 27 | 32 | ||
| 28 | - git clone --depth=1 --branch="v$NPM_VERSION" git@github.com:npm/cli.git | ||
| 29 | - cd cli | ||
| 33 | + NPM_TGZ=npm.tgz | ||
| 30 | 34 | ||
| 31 | - echo "Preparing npm release" | ||
| 35 | + NPM_TARBALL="$($NODE "$NPM" view npm@"$NPM_VERSION" dist.tarball)" | ||
| 32 | 36 | ||
| 33 | - make | ||
| 34 | - make release | ||
| 37 | + curl -s "$NPM_TARBALL" > "$NPM_TGZ" | ||
| 35 | 38 | ||
| 36 | - echo "Removing old npm" | ||
| 39 | + rm -rf "$DEPS_DIR/npm" | ||
| 37 | 40 | ||
| 38 | - cd "$DEPS_DIR" | ||
| 39 | - rm -rf npm/ | ||
| 41 | + mkdir "$DEPS_DIR/npm" | ||
| 40 | 42 | ||
| 41 | - echo "Copying new npm" | ||
| 42 | - | ||
| 43 | - tar zxf "$WORKSPACE/cli/release/npm-$NPM_VERSION.tgz" | ||
| 43 | + tar zxvf "$NPM_TGZ" --strip-component=1 -C "$DEPS_DIR/npm" | ||
| 44 | 44 | ||
| 45 | 45 | echo "" | |
| 46 | 46 | echo "All done!" | |
@@ -49,5 +49,8 @@ echo "Please git add npm, commit the new version, and whitespace-fix:" | |||
| 49 | 49 | echo "" | |
| 50 | 50 | echo "$ git add -A deps/npm" | |
| 51 | 51 | echo "$ git commit -m \"deps: upgrade npm to $NPM_VERSION\"" | |
| 52 | - echo "$ git rebase --whitespace=fix main" | ||
| 53 | 52 | echo "" | |
| 53 | + | ||
| 54 | + # The last line of the script should always print the new version, | ||
| 55 | + # as we need to add it to $GITHUB_ENV variable. | ||
| 56 | + echo "NEW_VERSION=$NPM_VERSION" | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments