#!/bin/sh # Shell script to update undici in the source tree to the latest release. # This script must be in the tools directory when it runs because it uses the # script source file path to determine directories to work in. set -ex ROOT=$(cd "$(dirname "$0")/../.." && pwd) [ -z "$NODE" ] && NODE="$ROOT/out/Release/node" [ -x "$NODE" ] || NODE=$(command -v node) NPM="$ROOT/deps/npm/bin/npm-cli.js" NEW_VERSION=$("$NODE" "$NPM" view undici dist-tags.latest) CURRENT_VERSION=$("$NODE" -p "require('./deps/undici/src/package.json').version") echo "Comparing $NEW_VERSION with $CURRENT_VERSION" if [ "$NEW_VERSION" = "$CURRENT_VERSION" ]; then echo "Skipped because Undici is on the latest version." exit 0 fi cd "$( dirname "$0" )/../.." || exit rm -rf deps/undici/src rm -f deps/undici/undici.js ( rm -rf undici-tmp mkdir undici-tmp cd undici-tmp || exit "$NODE" "$NPM" init --yes "$NODE" "$NPM" install --global-style --no-bin-links --ignore-scripts "undici@$NEW_VERSION" cd node_modules/undici "$NODE" "$NPM" install --no-bin-link --ignore-scripts "$NODE" "$NPM" run build:node "$NODE" "$NPM" prune --production rm node_modules/.package-lock.json ) # update version information in src/undici_version.h cat > "$ROOT/src/undici_version.h" <