| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,5 +1,5 @@ | |||
| 1 | 1 | #!/bin/sh | |
| 2 | - set -e | ||
| 2 | + set -ex | ||
| 3 | 3 | ||
| 4 | 4 | # Shell script to update llhttp in the source tree to specific version | |
| 5 | 5 | ||
@@ -8,12 +8,14 @@ DEPS_DIR="${BASE_DIR}/deps" | |||
| 8 | 8 | ||
| 9 | 9 | [ -z "$NODE" ] && NODE="$BASE_DIR/out/Release/node" | |
| 10 | 10 | [ -x "$NODE" ] || NODE=$(command -v node) | |
| 11 | + NPM_DIR="$DEPS_DIR/npm/bin" | ||
| 12 | + NPM="$NPM_DIR/npm-cli.js" | ||
| 11 | 13 | ||
| 12 | 14 | # shellcheck disable=SC1091 | |
| 13 | 15 | . "$BASE_DIR/tools/dep_updaters/utils.sh" | |
| 14 | 16 | ||
| 15 | 17 | if [ -n "$LOCAL_COPY" ]; then | |
| 16 | - NEW_VERSION=$(node -e "console.log(JSON.parse(require('fs').readFileSync('$LOCAL_COPY/package.json', 'utf-8')).version)") | ||
| 18 | + NEW_VERSION=$(PACKAGE_JSON="$LOCAL_COPY/package.json" node -p "require(process.env.PACKAGE_JSON).version") | ||
| 17 | 19 | else | |
| 18 | 20 | NEW_VERSION="$("$NODE" --input-type=module <<'EOF' | |
| 19 | 21 | const res = await fetch('https://api.github.com/repos/nodejs/llhttp/releases/latest', | |
@@ -47,51 +49,27 @@ echo "Making temporary workspace ..." | |||
| 47 | 49 | WORKSPACE=$(mktemp -d 2> /dev/null || mktemp -d -t 'tmp') | |
| 48 | 50 | trap cleanup INT TERM EXIT | |
| 49 | 51 | ||
| 50 | - cd "$WORKSPACE" | ||
| 52 | + if [ -z "$LOCAL_COPY" ]; then | ||
| 53 | + echo "Downloading llhttp source..." | ||
| 54 | + curl -fsSL "https://github.com/nodejs/llhttp/archive/refs/tags/v$NEW_VERSION.tar.gz" | tar xz -C "$WORKSPACE" | ||
| 55 | + | ||
| 56 | + LOCAL_COPY="$(find "$WORKSPACE" -mindepth 1 -maxdepth 1 -type d -print -quit)" | ||
| 57 | + fi | ||
| 51 | 58 | ||
| 52 | 59 | echo "Replacing existing llhttp (except GYP and GN build files)" | |
| 53 | 60 | mv "$DEPS_DIR/llhttp/"*.gn "$DEPS_DIR/llhttp/"*.gni "$WORKSPACE/" | |
| 54 | 61 | ||
| 55 | - if [ -n "$LOCAL_COPY" ]; then | ||
| 56 | - echo "Copying llhttp release from $LOCAL_COPY ..." | ||
| 57 | - | ||
| 58 | - echo "Building llhttp ..." | ||
| 59 | - cd "$BASE_DIR" | ||
| 62 | + echo "Building llhttp ..." | ||
| 63 | + ( | ||
| 60 | 64 | cd "$LOCAL_COPY" | |
| 61 | - npm install | ||
| 65 | + "$NODE" "$NPM" ci --ignore-scripts | ||
| 66 | + "$NODE" "$NPM" exec tsc | ||
| 62 | 67 | RELEASE=$NEW_VERSION make release | |
| 68 | + ) | ||
| 63 | 69 | ||
| 64 | - echo "Copying llhttp release ..." | ||
| 65 | - rm -rf "$DEPS_DIR/llhttp" | ||
| 66 | - cp -a release "$DEPS_DIR/llhttp" | ||
| 67 | - elif echo "$NEW_VERSION" | grep -qs "/" ; then # Download a release | ||
| 68 | - REPO="git@github.com:$NEW_VERSION.git" | ||
| 69 | - BRANCH=$2 | ||
| 70 | - [ -z "$BRANCH" ] && BRANCH=main | ||
| 71 | - | ||
| 72 | - echo "Cloning llhttp source archive $REPO ..." | ||
| 73 | - git clone "$REPO" llhttp | ||
| 74 | - cd llhttp | ||
| 75 | - echo "Checking out branch $BRANCH ..." | ||
| 76 | - git checkout "$BRANCH" | ||
| 77 | - | ||
| 78 | - echo "Building llhttp ..." | ||
| 79 | - npm install | ||
| 80 | - RELEASE=$NEW_VERSION make release | ||
| 81 | - | ||
| 82 | - echo "Copying llhttp release ..." | ||
| 83 | - rm -rf "$DEPS_DIR/llhttp" | ||
| 84 | - cp -a release "$DEPS_DIR/llhttp" | ||
| 85 | - else | ||
| 86 | - echo "Download llhttp release $NEW_VERSION ..." | ||
| 87 | - LLHTTP_TARBALL="llhttp-v$NEW_VERSION.tar.gz" | ||
| 88 | - curl -sL -o "$LLHTTP_TARBALL" "https://github.com/nodejs/llhttp/archive/refs/tags/release/v$NEW_VERSION.tar.gz" | ||
| 89 | - gzip -dc "$LLHTTP_TARBALL" | tar xf - | ||
| 90 | - | ||
| 91 | - echo "Copying llhttp release ..." | ||
| 92 | - rm -rf "$DEPS_DIR/llhttp" | ||
| 93 | - cp -a "llhttp-release-v$NEW_VERSION" "$DEPS_DIR/llhttp" | ||
| 94 | - fi | ||
| 70 | + echo "Overwriting vendored files..." | ||
| 71 | + rm -rf "$DEPS_DIR/llhttp" | ||
| 72 | + cp -a "$LOCAL_COPY/release" "$DEPS_DIR/llhttp" | ||
| 95 | 73 | ||
| 96 | 74 | mv "$WORKSPACE/"*.gn "$WORKSPACE/"*.gni "$DEPS_DIR/llhttp" | |
| 97 | 75 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments