Skip to content

Commit 37e62e8

Browse files
Add "commaize" script to add trailing commas
If people want automatically add trailing commas in labs, here's a script to do it. Signed-off-by: David A. Wheeler <[email protected]>
1 parent 913f59f commit 37e62e8

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

docs/labs/commaize

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/sh
2+
# Add trailing commas and terminating semicolon to lab data files
3+
4+
for file in [a-z]*.js
5+
do
6+
# Skip checker, that has more than data in it.
7+
if [ "$file" == 'checker.js' ]; then
8+
continue
9+
fi
10+
11+
# Skip anything that isn't a lab data file.
12+
if ! grep -q 'info =' "$file"; then
13+
continue
14+
fi
15+
16+
htmlfile="${file%.js}.html"
17+
echo "Modifying $file for $htmlfile"
18+
19+
sed -E -e 's/^( +(\]|\}))$/\1,/' -e '$s/^\}$/};/' "$file" > ,1
20+
mv ,1 "$file"
21+
done

0 commit comments

Comments
 (0)