Skip to content

Commit 1bd764d

Browse files
committed
Use Node script for about.md generation
1 parent f177d9d commit 1bd764d

File tree

2 files changed

+11
-39
lines changed

2 files changed

+11
-39
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -230,42 +230,7 @@ jobs:
230230
done
231231
shopt -u nullglob
232232
- name: create-about-md
233-
shell: bash
234-
run: |
235-
set -euo pipefail
236-
sudo apt-get update -y
237-
sudo apt-get install -y jq
238-
if [ -f documentation/modules.json ]; then
239-
jq -c '.[]' documentation/modules.json | while read -r mod; do
240-
id=$(echo "$mod" | jq -r '.public_uniqueID')
241-
dest="documentation/docs/modules/${id}"
242-
mkdir -p "$dest"
243-
{
244-
echo "# $(echo "$mod" | jq -r '.name')"
245-
echo ""
246-
echo "**Version:** $(echo "$mod" | jq -r '.version') "
247-
author=$(echo "$mod" | jq -r '.author')
248-
[ -n "$author" ] && echo "**Author:** $author "
249-
discord=$(echo "$mod" | jq -r '.discord')
250-
[ -n "$discord" ] && echo "**Discord:** $discord "
251-
desc=$(echo "$mod" | jq -r '.description')
252-
[ -n "$desc" ] && { echo ""; echo "$desc"; echo ""; }
253-
if [ "$(echo "$mod" | jq -r '.features | length')" -gt 0 ]; then
254-
echo "## Features"
255-
echo ""
256-
echo "$mod" | jq -r '.features[] | "- " + .'
257-
echo ""
258-
fi
259-
if [ "$(echo "$mod" | jq -r '.workshop | length')" -gt 0 ]; then
260-
echo "## Workshop Content"
261-
echo ""
262-
echo "$mod" | jq -r '.workshop[] | "- " + .'
263-
echo ""
264-
fi
265-
echo "[Download]($(echo "$mod" | jq -r '.download'))"
266-
} > "$dest/about.md"
267-
done
268-
fi
233+
run: node generate_about_md.js
269234
- name: clean-obsolete-docs
270235
run: |
271236
rm -rf documentation/docs/hooks/modules

generate_about_md.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
const fs = require('fs')
22
const path = require('path')
33

4-
const modulesPath = path.join(__dirname, 'modules.json')
5-
if (!fs.existsSync(modulesPath)) process.exit(1)
4+
let modulesPath = path.join(__dirname, 'modules.json')
5+
if (!fs.existsSync(modulesPath)) {
6+
const altPath = path.join(__dirname, 'documentation', 'modules.json')
7+
if (fs.existsSync(altPath)) {
8+
modulesPath = altPath
9+
} else {
10+
process.exit(1)
11+
}
12+
}
613

714
let modules
815
try {
@@ -57,4 +64,4 @@ for (const mod of modules) {
5764
fs.writeFileSync(path.join(dest, 'about.md'), lines.join('\n'))
5865
}
5966

60-
console.log('about.md files generated.')
67+
console.log('about.md files generated.')

0 commit comments

Comments
 (0)