forked from missytake/doodle.xdc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
create-xdc.sh
executable file
·39 lines (35 loc) · 948 Bytes
/
create-xdc.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
39
#!/bin/sh
case "$1" in
"-h" | "--help")
echo "usage: ${0##*/} [PACKAGE_NAME]"
exit
;;
"")
PACKAGE_NAME=${PWD##*/} # '##*/' removes everything before the last slash and the last slash
;;
*)
PACKAGE_NAME=${1%.xdc} # '%.xdc' removes the extension and allows PACKAGE_NAME to be given with or without extension
;;
esac
rm "$PACKAGE_NAME.xdc" 2> /dev/null
zip -9 --recurse-paths "$PACKAGE_NAME.xdc" * --exclude \
README.md \
webxdc.js \
webxdc.d.ts \
package.json \
package-lock.json \
"src/*" \
"node_modules/*" \
bundle.js.map \
tsconfig.json \
.nvmrc \
"*.sh" \
"*.xdc"
echo "success, archive contents:"
unzip -l "$PACKAGE_NAME.xdc"
# check package size
MAXSIZE=102400
size=$(wc -c < "$PACKAGE_NAME.xdc")
if [ $size -ge $MAXSIZE ]; then
echo "WARNING: package size exceeded the limit ($size > $MAXSIZE)"
fi