mirror of
https://gitlab.postmarketos.org/postmarketOS/pmbootstrap.git
synced 2025-07-12 19:09:56 +03:00
Don't try to modify a variable in the while loop, as it runs in a subshell because of the pipe. Fail on the first error instead, like we have it in .ci/shellcheck.sh. This can be optimized later on (for both scripts) if we really want to. Fix for: In ./.ci/markdown.sh line 17: markdownlint-cli "$file" || MDL_FAILED=1 ^--------^ SC2030 (info): Modification of MDL_FAILED is local (to subshell caused by pipeline). In ./.ci/markdown.sh line 20: if [ "$MDL_FAILED" = "1" ]; then ^---------^ SC2031 (info): MDL_FAILED was modified in a subshell. That change might be lost.
33 lines
657 B
Bash
Executable file
33 lines
657 B
Bash
Executable file
#!/bin/sh -e
|
|
# Description: lint all markdown files
|
|
# https://postmarketos.org/pmb-ci
|
|
|
|
if [ "$(id -u)" = 0 ]; then
|
|
set -x
|
|
apk add npm
|
|
exec su "${TESTUSER:-build}" -c "sh -e $0"
|
|
fi
|
|
|
|
MDL="markdownlint-cli"
|
|
if ! command -v "$MDL" >/dev/null; then
|
|
MDL="$HOME/node_modules/markdownlint-cli/markdownlint.js"
|
|
if ! command -v "$MDL" >/dev/null; then
|
|
(cd ~;
|
|
set -x;
|
|
npm install markdownlint-cli)
|
|
fi
|
|
fi
|
|
if ! command -v "$MDL" >/dev/null; then
|
|
echo "ERROR: failed to find/install markdownlint"
|
|
exit 1
|
|
fi
|
|
|
|
find . -name '*.md' |
|
|
while read -r file; do
|
|
echo "mdl: $file"
|
|
if ! "$MDL" "$file"; then
|
|
echo
|
|
echo "markdown lint failed!"
|
|
exit 1
|
|
fi
|
|
done
|