aboutsummaryrefslogtreecommitdiff
path: root/scripts/assert-content.sh
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2020-02-06 03:46:19 -0300
committerEuAndreh <eu@euandre.org>2020-02-06 03:46:19 -0300
commit9451be4df72415352bcc7bf7eb43ec1d8011a871 (patch)
treeced37fd21cce82269d57efb0127cd084f1dbb546 /scripts/assert-content.sh
parentFormat default.nix with nixfmt (diff)
downloadeuandre.org-9451be4df72415352bcc7bf7eb43ec1d8011a871.tar.gz
euandre.org-9451be4df72415352bcc7bf7eb43ec1d8011a871.tar.xz
Fix shellcheck offenses
Diffstat (limited to '')
-rwxr-xr-xscripts/assert-content.sh31
1 files changed, 8 insertions, 23 deletions
diff --git a/scripts/assert-content.sh b/scripts/assert-content.sh
index 14fa688..f9ea345 100755
--- a/scripts/assert-content.sh
+++ b/scripts/assert-content.sh
@@ -45,21 +45,17 @@ assert-frontmatter() {
URL="$(get-url "$F")"
[[ -z "${LANG}" ]] && fail-attr 'lang' "${URL}"
[[ -z "${REF}" ]] && fail-attr 'ref' "${URL}"
- set +e
- contains-element "${LANG}" "${LANGS[@]}"
- [[ $? != 0 ]] && {
+ if ! contains-element "${LANG}" "${LANGS[@]}"; then
red "Invalid lang '${LANG}' in ${URL}." >&2
exit 1
- }
- set -e
- :
+ fi
}
echo Linting posts... >&2
for post in $(jq -r '.posts[] | @base64' "${JSON}"); do
assert-frontmatter "$post"
DATE="$(get-date "$post" | awk '{print $1}')"
- URL="$(basename $(get-url "$post"))"
+ URL="$(basename "$(get-url "$post")")"
FILE="_posts/${DATE}-${URL%.html}.md"
[[ -f "${FILE}" ]] || {
@@ -69,16 +65,12 @@ for post in $(jq -r '.posts[] | @base64' "${JSON}"); do
done
echo Linting pages... >&2
-IGNORED_PAGES=(/site.json /sitemap.xml /feed.all.atom /feed.en.atom /feed.pt.atom)
+IGNORED_PAGES=(/site.json /sitemap.xml /rss.xml /atom.xml /feed.atom /feed.xml /feed.all.atom /feed.en.atom /feed.pt.atom)
for page in $(jq -r '.pages[] | @base64' "${JSON}"); do
URL="$(get-url "$page")"
- set +e
- contains-element "${URL}" "${IGNORED_PAGES[@]}"
- if [[ $? != 0 ]]; then
- set -e
+ if ! contains-element "${URL}" "${IGNORED_PAGES[@]}"; then
assert-frontmatter "${page}"
fi
- set -e
done
echo Linting pastebins... >&2
@@ -90,25 +82,18 @@ echo Asserting unique refs... >&2
KNOWN_IDS=()
for page in $(jq -r '.pages[] | @base64' "${JSON}"); do
URL="$(get-url "$page")"
- set +e
- contains-element "${URL}" "${IGNORED_PAGES[@]}"
- if [[ $? != 0 ]]; then
- set -e
+ if ! contains-element "${URL}" "${IGNORED_PAGES[@]}"; then
LANG="$(get-lang "$page")"
REF="$(get-ref "$page")"
ID="${LANG}:${REF}"
- set +e
- contains-element "${ID}" "${KNOWN_IDS[@]}"
- [[ $? == 0 ]] && {
+ if contains-element "${ID}" "${KNOWN_IDS[@]}"; then
red "Duplicated lang:ref match: '${ID}'." >&2
exit 1
- }
- set -e
+ fi
KNOWN_IDS+=("${ID}") # printf '%s\n' "${KNOWN_IDS[@]}"
fi
- set -e
done
echo Done. >&2