Skip to content

Commit 26a6ae8

Browse files
committed
chore: enable pipefail for snapcraft.yaml.sh (#39)
Trap empty `NODE_VERSION`, e.g. if fetching `index.tab` fails. Refs: #38
1 parent 3d2b1bf commit 26a6ae8

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

snapcraft.yaml.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

3-
set -xe
3+
set -euxo pipefail
44

55
__dirname="$(CDPATH= cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
66
STRIP_NPX=no
@@ -10,7 +10,7 @@ while getopts "r:g:" opt; do
1010
r)
1111
echo "Updating for latest $OPTARG release" >&2
1212
# release
13-
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 }')"
13+
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) }')"
1414
NODE_DISTTYPE="release"
1515
NODE_TAG=""
1616
if [ "X${OPTARG}" = "X6" ]; then
@@ -32,7 +32,7 @@ done
3232
# not a release?
3333
if [ -z ${NODE_DISTTYPE+x} ]; then
3434
# nightly
35-
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 }')"
35+
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) }')"
3636
NODE_DISTTYPE="nightly"
3737
NODE_TAG="$(echo $NODE_VERSION | sed -E 's/^[^-]+-//')"
3838
fi

0 commit comments

Comments
 (0)