-
Notifications
You must be signed in to change notification settings - Fork 0
/
pack.sh
33 lines (27 loc) · 1005 Bytes
/
pack.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
#!/usr/bin/env bash
file="extension/manifest.json"
version=$(cat "$file" | grep "\"version\"" | cut -d ":" -f2 | cut -d "," -f1 | cut -d "\"" -f2)
bumped=""
# If `bump` passed in as argument, increment manifest.json version
if [ $# -eq 1 ] && [ "$1" == "bump" ]
then
# Reference: http://stackoverflow.com/a/6245903/
inc_version="${version%.*}.$((${version##*.}+1))"
# Reference: http://stackoverflow.com/a/525606/
echo "%s/$version/$inc_version/g
w
q
" | ex $file
version=$inc_version
bumped=" (bumped)"
fi
name=$(cat "$file" | grep "\"name\"" | cut -d ":" -f2 | cut -d "," -f1 | cut -d "\"" -f2)
echo "Current$bumped version# of $name is: $version" # so that it would print correctly
find . -type f -name "$name-*.zip" -exec rm {} +
if [[ "$OSTYPE" == "darwin"* ]]; then
# Mac OSX, so remove all .DS_Stores
echo "Removing .DS_Stores..."
find . -name '*.DS_Store' -type f -delete
echo "Done."
fi
zip -r "$name-$version".zip extension/