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