Skip to content

Commit b878202

Browse files
committed
build: Build accepts version argument
`npm run build` continues to build all versions `npm run build 3.0.0` builds a specific version `npm run build latest` builds from the latest spec
1 parent 031d633 commit b878202

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

scripts/md2html/build.sh

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,24 @@ cp -p ../../node_modules/respec/builds/respec-w3c.* ../../deploy/js/
1515
latest=`git describe --abbrev=0 --tags`
1616
latestCopied=none
1717
lastMinor="-"
18-
for filename in $(ls -1 ../../versions/[23456789].*.md | sort -r) ; do
19-
if [[ ${filename} == *-editors.md ]];then
18+
19+
# If $1 is not provided, process all versions
20+
# If $1 is "latest", process the last-tagged version
21+
# Otherwise, process the specified version
22+
if [ -z "$1" ]; then
23+
files=$(ls -1 ../../versions/[23456789].*.md | sort -r)
24+
elif [ "$1" = "latest" ]; then
25+
files="../../versions/$latest.md"
26+
elif [ -f "../../versions/$1.md" ]; then
27+
files="../../versions/$1.md"
28+
else
29+
echo "Error: version $1.md not found"
30+
exit 1
31+
fi
32+
33+
for filename in $files; do
34+
35+
if [[ ${filename} == *-editors.md ]]; then
2036
continue
2137
fi
2238

@@ -30,7 +46,7 @@ for filename in $(ls -1 ../../versions/[23456789].*.md | sort -r) ; do
3046
rm $tempfile
3147

3248
if [ $version = $latest ]; then
33-
if [[ ${version} != *"rc"* ]];then
49+
if [[ ${version} != *"rc"* ]]; then
3450
# version is not a Release Candidate
3551
( cd ../../deploy/oas && ln -sf v$version.html latest.html )
3652
latestCopied=v$version

0 commit comments

Comments
 (0)