1#!/bin/sh 2 3# Shell script to update minimatch 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 minimatch dist-tags.latest) 16CURRENT_VERSION=$("$NODE" -p "require('./deps/minimatch/src/package.json').version") 17 18echo "Comparing $NEW_VERSION with $CURRENT_VERSION" 19 20if [ "$NEW_VERSION" = "$CURRENT_VERSION" ]; then 21 echo "Skipped because minimatch is on the latest version." 22 exit 0 23fi 24 25cd "$( dirname "$0" )/../.." || exit 26 27rm -rf deps/minimatch/src 28rm -rf deps/minimatch/index.js 29 30( 31 rm -rf minimatch-tmp 32 mkdir minimatch-tmp 33 cd minimatch-tmp || exit 34 35 "$NODE" "$NPM" init --yes 36 37 "$NODE" "$NPM" install --global-style --no-bin-links --ignore-scripts "minimatch@$NEW_VERSION" 38 cd node_modules/minimatch 39 "$NODE" "$NPM" exec --package=esbuild@0.17.15 --yes -- esbuild ./dist/cjs/index.js --bundle --platform=node --outfile=minimatch.js 40) 41 42ls -l minimatch-tmp 43mv minimatch-tmp/node_modules/minimatch deps/minimatch/src 44mv deps/minimatch/src/minimatch.js deps/minimatch/index.js 45cp deps/minimatch/src/LICENSE deps/minimatch/LICENSE 46 47rm -rf minimatch-tmp/ 48 49echo "All done!" 50echo "" 51echo "Please git add minimatch, commit the new version:" 52echo "" 53echo "$ git add -A deps/minimatch" 54echo "$ git commit -m \"deps: update minimatch to $NEW_VERSION\"" 55echo "" 56 57# The last line of the script should always print the new version, 58# as we need to add it to $GITHUB_ENV variable. 59echo "NEW_VERSION=$NEW_VERSION" 60