-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
87 lines (70 loc) · 2.04 KB
/
build.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/bin/bash
# e.g. "bash build.sh" or "bash build.sh popup zip"
# exit on error
set -e
function log() {
BLUE='\033[1;34m'
NO_COLOR='\033[0m'
echo -e "[$BLUE $1 $NO_COLOR]"
}
action=" $1 $2 $3 $4 $5 "
if [ ${#action} == "6" ]; then
action=""
fi;
if [ -z "$action" ] || [[ "$action" =~ " clean " ]]; then
log "clean"
rm -rf build && mkdir build
rm -f build.zip
fi
if [ -z "$action" ] || [[ "$action" =~ " manifest " ]]; then
log "manifest"
node chrome/manifest.build.js > build/manifest.json
fi
if [ -z "$action" ] || [[ "$action" =~ " locales " ]]; then
log "locales"
cp -TR chrome/_locales build/_locales
fi
if [ -z "$action" ] || [[ "$action" =~ " images " ]]; then
log "images"
mkdir -p build/img
cp chrome/img/iconOff32.png chrome/img/iconOn32.png chrome/img/icon64.png build/img/
fi
if [ -z "$action" ] || [[ "$action" =~ " content " ]]; then
log "content"
cp -TR chrome/content build/content/
fi
if [ -z "$action" ] || [[ "$action" =~ " popup " ]]; then
log "popup"
cp -TR chrome/popup build/popup/
fi
if [ -z "$action" ] || [[ "$action" =~ " background-npm-install " ]]; then
log "background-npm-install"
npm ci --prefix chrome/background
fi
if [ -z "$action" ] || [[ "$action" =~ " background-test " ]]; then
log "background-test"
npm run test --prefix chrome/background
fi
if [ -z "$action" ] || [[ "$action" =~ " background-build " ]]; then
log "background-build"
rm -rf chrome/background/build
npm run build --prefix chrome/background
cp -TR chrome/background/build build/background
fi
if [ -z "$action" ] || [[ "$action" =~ " options-npm-install " ]]; then
log "options-npm-install"
npm ci --prefix chrome/options
fi
if [ -z "$action" ] || [[ "$action" =~ " options-build " ]]; then
log "options-build"
npm run build --prefix chrome/options
cp -TR chrome/options/build build/options
fi
if [ -z "$action" ] || [[ "$action" =~ " zip " ]]; then
log "zip"
cd build
version=$(cat manifest.json | jq ".version" | tr -d ".\"")
zip -rq build.zip ./*
cd ..
mv build/build.zip ./build$version.zip
fi