diff options
Diffstat (limited to '')
-rwxr-xr-x | scripts/assert-content.sh | 31 |
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 |