Changes to build for README.md updates

* Make the number of packages in the project easier to find.
* Replace `ed` with `awk` in `update_readme()`, the latter being (_arguably_!) more readable/less fragile.
This commit is contained in:
Dan Reif
2018-06-05 16:41:17 -07:00
parent d4da7817ba
commit 33f610feb7
2 changed files with 23 additions and 11 deletions

30
build
View File

@@ -127,17 +127,27 @@ copy_file() {
}
update_readme() {
ed README.md <<- EOF
/Language packs
+2kb
/##
'b,-2c
$(echo -n "$OUTPUT" | sort)
.
w
q
EOF
local tf of
tf="$(mktemp)"
of="$(mktemp)"
sort <<<"$OUTPUT" | grep -vxE '[[:space:]]*' > "$of"
awk 'suppress == 0 {
gsub(/<!--Package Count-->[^<]*<!--\/Package Count-->/,
"<!--Package Count-->'"$(awk 'END {print NR}' "$of")"'<!--/Package Count-->");
print;
}
/<!--Language Packs-->/ {
suppress = 1;
while ( ( getline line < "'"$of"'" ) > 0 ) {
print line;
}
}
/<!--\/Language Packs-->/ {
suppress = 0;
print;
}' "README.md" >"$tf"
mv "$tf" "README.md"
}
PACKS="