1#!/bin/sh 2 3# Shell script to update acorn-walk in the source tree to the latest release. 4 5# This script must be in the tools directory when it runs because it uses the 6# script source file path to determine directories to work in. 7 8set -ex 9 10ROOT=$(cd "$(dirname "$0")/../.." && pwd) 11[ -z "$NODE" ] && NODE="$ROOT/out/Release/node" 12[ -x "$NODE" ] || NODE=$(command -v node) 13NPM="$ROOT/deps/npm/bin/npm-cli.js" 14 15NEW_VERSION=$("$NODE" "$NPM" view acorn-walk dist-tags.latest) 16CURRENT_VERSION=$("$NODE" -p "require('./deps/acorn/acorn-walk/package.json').version") 17 18echo "Comparing $NEW_VERSION with $CURRENT_VERSION" 19 20if [ "$NEW_VERSION" = "$CURRENT_VERSION" ]; then 21 echo "Skipped because Acorn-walk is on the latest version." 22 exit 0 23fi 24 25cd "$( dirname "$0" )/../.." || exit 26 27rm -rf deps/acorn/acorn-walk 28 29( 30 rm -rf acorn-walk-tmp 31 mkdir acorn-walk-tmp 32 cd acorn-walk-tmp || exit 33 34 "$NODE" "$NPM" init --yes 35 36 "$NODE" "$NPM" install --global-style --no-bin-links --ignore-scripts "acorn-walk@$NEW_VERSION" 37) 38 39mv acorn-walk-tmp/node_modules/acorn-walk deps/acorn 40 41rm -rf acorn-walk-tmp/ 42 43echo "All done!" 44echo "" 45echo "Please git add acorn-walk, commit the new version:" 46echo "" 47echo "$ git add -A deps/acorn-walk" 48echo "$ git commit -m \"deps: update acorn-walk to $NEW_VERSION\"" 49echo "" 50 51# The last line of the script should always print the new version, 52# as we need to add it to $GITHUB_ENV variable. 53echo "NEW_VERSION=$NEW_VERSION" 54