Merge pull request #4892 from chrishollandaise/sed-portable-lint

Add additional sh lint check for incompatible sed -i cases
This commit is contained in:
Oliver Blanthorn 2024-01-23 19:00:17 +00:00 committed by GitHub
commit d59a9d96bb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 7 additions and 2 deletions

View file

@ -5,5 +5,10 @@ if [ -x "$(command -v shellcheck)" ]; then
else
echo "Warning: shellcheck is not installed, skipping shell scripts"
fi
incompatible_sed=$(! grep -RPn --color=always --exclude-dir=node_modules --exclude-dir=.git 'sed(?:\s-\w+)*\s-i(?!\S|\s"")')
if [ "$incompatible_sed" ]; then
printf "\nWarning: avoid non-portable sed flag -i without backup extension, use -i.bak\n"
printf "%s\n\n" "$incompatible_sed"
fi
yarn run lint
"$(yarn bin)/eslint" --rulesdir custom-eslint-rules --ext .ts .

View file

@ -1,4 +1,4 @@
#!/bin/sh
# Replace issue numbers in brackets eg (#1337) with a link to the issue on the repository
sed -i 's; (#\([0-9]*\)); ([#\1](https://github.com/tridactyl/tridactyl/issues/\1));g' CHANGELOG.md
sed -i.bak 's; (#\([0-9]*\)); ([#\1](https://github.com/tridactyl/tridactyl/issues/\1));g' CHANGELOG.md

View file

@ -16,5 +16,5 @@ do
sed "/REPLACETHIS/,$ d" tutor.template.html > "$dest$fileroot.html"
"$(yarn bin)/marked" "$page" >> "$dest$fileroot.html"
sed "1,/REPLACETHIS/ d" tutor.template.html >> "$dest$fileroot.html"
sed -i "s|\.md|.html|g" "$dest$fileroot.html"
sed -i.bak "s|\.md|.html|g" "$dest$fileroot.html"
done