diff options
author | EuAndreh <eu@euandre.org> | 2020-12-26 09:50:47 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2020-12-26 09:50:57 -0300 |
commit | 77f78bb8562a0178a1434261cf5ab6ea8849fd13 (patch) | |
tree | d3a27ffbfcf4265a077b8d81b608d1a33e8090f0 | |
parent | Remove generated media extensions (.ogg, .torrent) from gitignore (diff) | |
download | euandre.org-77f78bb8562a0178a1434261cf5ab6ea8849fd13.tar.gz euandre.org-77f78bb8562a0178a1434261cf5ab6ea8849fd13.tar.xz |
Use /bin/sh over Bash everywhere, remove patchShebangs from default.nix
Diffstat (limited to '')
-rw-r--r-- | default.nix | 32 | ||||
-rwxr-xr-x | scripts/apply-translations.sh | 7 | ||||
-rwxr-xr-x | scripts/assert-spelling.sh | 19 | ||||
-rwxr-xr-x | scripts/extract-translations.sh | 11 |
4 files changed, 28 insertions, 41 deletions
diff --git a/default.nix b/default.nix index 8d29ca6..d8acf76 100644 --- a/default.nix +++ b/default.nix @@ -36,26 +36,20 @@ let niv (hunspellWithDicts (with utils-i18n.dicts; [ en pt fr eo ])) ]; + drv = name: buildPhase: + pkgs.stdenv.mkDerivation { + inherit src buildInputs buildPhase; + name = "website-${name}"; + phases = [ "unpackPhase" "buildPhase" ]; + }; in rec { - site = pkgs.stdenv.mkDerivation { - inherit src buildInputs; - name = "website-site"; - phases = [ "unpackPhase" "buildPhase" ]; - buildPhase = '' - patchShebangs . - jekyll build -d $out --trace - ''; - }; - test = pkgs.stdenv.mkDerivation { - inherit src buildInputs; - name = "website-test"; - phases = [ "unpackPhase" "buildPhase" ]; - buildPhase = '' - patchShebangs . - ./tests.sh - touch $out - ''; - }; + site = drv "site" '' + jekyll build -d $out --trace + ''; + test = drv "test" '' + ./tests.sh + touch $out + ''; shell = pkgs.mkShell { inherit buildInputs; name = "website-shell"; diff --git a/scripts/apply-translations.sh b/scripts/apply-translations.sh index 291de76..1148b60 100755 --- a/scripts/apply-translations.sh +++ b/scripts/apply-translations.sh @@ -1,11 +1,8 @@ -#!/usr/bin/env bash -set -Eeuo pipefail -cd "$(dirname "${BASH_SOURCE[0]}")" -cd ../ +#!/bin/sh -eu for f in $(git ls-files | grep -E '.(md|slides)$' | grep -v '^vendor/reveal.js$'); do l="$(grep '^lang: ..$' "$f" | awk '{print $2}')" - if [[ "$l" != 'en' ]]; then + if [ "$l" != 'en' ]; then ref="$(grep '^ref: ' "$f" | awk '{print $2}')" # shellcheck disable=2046 FROM=$(find $(find . -name '*.md' -exec grep -l "^ref: $ref$" {} \;) -exec grep -l '^lang: en$' {} \;) diff --git a/scripts/assert-spelling.sh b/scripts/assert-spelling.sh index 615fddc..f4ab58e 100755 --- a/scripts/assert-spelling.sh +++ b/scripts/assert-spelling.sh @@ -1,12 +1,9 @@ -#!/usr/bin/env bash -set -Eeuo pipefail -cd "$(dirname "${BASH_SOURCE[0]}")" -cd ../ +#!/bin/sh -eu export LANG=C.UTF-8 for DICT in scripts/spelling/*.txt; do - diff <(sort "$DICT") "$DICT" || { + sort "$DICT" | diff - "$DICT" || { echo "The $DICT dictionary is unsorted. To fix it, run:" >&2 echo " LANG=C.UTF-8 sort $DICT | sponge $DICT" >&2 exit 1 @@ -14,16 +11,18 @@ for DICT in scripts/spelling/*.txt; do done OUT="$(mktemp)" -shopt -s globstar jekyll build --future --trace -for f in _site/**/*.html; do - if ! grep -E '^_site/vendor/' <(echo "$f") > /dev/null; then +# shellcheck disable=2044 +for f in $(find _site -type f -name '*.html'); do + if ! echo "$f" | grep -E '^_site/vendor/' > /dev/null; then l="$(head -n2 "$f" | tail -n1 | cut -d\" -f2)" - hunspell -u3 -H -d "$l" -p <(cat scripts/spelling/international.txt "scripts/spelling/$l.txt") "$f" | tee -a "$OUT" + CURR_DICT="$(mktemp)" + cat scripts/spelling/international.txt "scripts/spelling/$l.txt" > "$CURR_DICT" + hunspell -u3 -H -d "$l" -p "$CURR_DICT" "$f" | tee -a "$OUT" fi done -if [[ -s "$OUT" ]]; then +if [ -s "$OUT" ]; then printf "\nvvv Mispelled words detected by hunspell.\n\n" cut -d\ -f2- < "$OUT" | sort | uniq printf "\n^^^\n" >&2 diff --git a/scripts/extract-translations.sh b/scripts/extract-translations.sh index 13fc160..ea4b0f5 100755 --- a/scripts/extract-translations.sh +++ b/scripts/extract-translations.sh @@ -1,14 +1,11 @@ -#!/usr/bin/env bash -set -Eeuo pipefail -cd "$(dirname "${BASH_SOURCE[0]}")" -cd ../ +#!/bin/sh -eu -TRANSLATIONS=(pt fr eo) +TRANSLATIONS='pt fr eo' for f in $(git ls-files | grep -E '.(md|slides)$' | grep -v '^vendor/reveal.js$'); do file_lang="$(grep '^lang: ..$' "$f" | awk '{print $2}')" - if [[ "$file_lang" = 'en' ]]; then - for l in "${TRANSLATIONS[@]}"; do + if [ "$file_lang" = 'en' ]; then + for l in $TRANSLATIONS; do OUT="locale/$l/LC_MESSAGES/${f%.md}.po" mkdir -p "$(dirname "$OUT")" md2po "$f" --include-codeblocks --quiet --save --po-filepath "$OUT" |