Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions snapcraft.yaml.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

set -xe
set -euxo pipefail

__dirname="$(CDPATH= cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
STRIP_NPX=no
Expand All @@ -10,7 +10,7 @@ while getopts "r:g:" opt; do
r)
echo "Updating for latest $OPTARG release" >&2
# release
NODE_VERSION="$(curl -sL https://nodejs.org/download/release/index.tab | awk '/^v'"$OPTARG"'\..*[^a-z0-9]src[^a-z0-9]/ { print substr($1, 2); exit }')"
NODE_VERSION="$(curl -sL --show-error --fail https://nodejs.org/download/release/index.tab | awk 'BEGIN { found = 0 } /^v'"$OPTARG"'\..*[^a-z0-9]src[^a-z0-9]/ && !found { found = 1; print substr($1, 2) }')"
NODE_DISTTYPE="release"
NODE_TAG=""
if [ "X${OPTARG}" = "X6" ]; then
Expand All @@ -36,7 +36,7 @@ done
# not a release?
if [ -z ${NODE_DISTTYPE+x} ]; then
# nightly
NODE_VERSION="$(curl -sL https://nodejs.org/download/nightly/index.tab | awk '/^v[1-9].*[^a-z0-9]src[^a-z0-9]/ { print substr($1, 2); exit }')"
NODE_VERSION="$(curl -sL --show-error --fail https://nodejs.org/download/nightly/index.tab | awk 'BEGIN { found = 0 } /^v[1-9].*[^a-z0-9]src[^a-z0-9]/ && !found { found = 1; print substr($1, 2) }')"
Copy link
Member Author

@richardlau richardlau May 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes to the awk script are to make awk read all of the input. Previously the script contained an early exit which causes curl to exit with exit code 23 as the pipe is closed by awk before curl has finished writing to it. This was masked before by the -s (silent) curl option but surfaced when pipefail was enabled.
e.g. https://github.com/nodejs/snap/runs/6322739611?check_suite_focus=true

NODE_DISTTYPE="nightly"
NODE_TAG="$(echo $NODE_VERSION | sed -E 's/^[^-]+-//')"
fi
Expand Down