Skip to content

Commit 0261e4e

Browse files
author
Gabriel Schulhof
committed
set-lib-versions.sh: Script to replace core and mobile version in entries2html.xsl and resources/
1 parent f93cc97 commit 0261e4e

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

set-lib-versions.sh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/sh
2+
3+
replace_libs() { # $1 is $core_version $2 is $jqm_version $3 is $file
4+
5+
core_version="$1"
6+
jqm_version="$2"
7+
filename="$3"
8+
9+
tmpfile="$( mktemp )"
10+
11+
cat "$filename" | \
12+
sed -r "s@(//code.jquery.com/jquery-)([0-9]+\.[0-9]+\.[0-9]+)@\1$core_version@g" | \
13+
sed -r "s@(//code.jquery.com/mobile/)([^/]*)/jquery.mobile-(.*).min@\1$jqm_version/jquery.mobile-$jqm_version.min@g" \
14+
> "$tmpfile" &&
15+
mv "$tmpfile" "$filename"
16+
rm -f "$tmpfile"
17+
}
18+
19+
core_version="$1"
20+
jqm_version="$2"
21+
22+
if test "x$core_version" = "x" -o "x$jqm_version" = "x"; then
23+
echo "Modifies entries2html.xsl and the examples in resources/ with the given version of core and mobile."
24+
echo "Commit the result if you wish to make the change permanent."
25+
echo ""
26+
echo "Usage: $(basename $0) <core_version> <jqm_version>"
27+
exit 1
28+
fi
29+
30+
if ! echo "$core_version" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+$'; then
31+
echo "Core version must be of the form xxx.yyy.zzz where xxx, yyy, and zzz are numbers."
32+
exit 2
33+
fi
34+
35+
find resources -type f | while read; do
36+
replace_libs "$core_version" "$jqm_version" "$REPLY"
37+
done
38+
replace_libs "$core_version" "$jqm_version" entries2html.xsl

0 commit comments

Comments
 (0)