-
Notifications
You must be signed in to change notification settings - Fork 0
/
build
executable file
·74 lines (58 loc) · 1.06 KB
/
build
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
#!/bin/bash
set -e
set -x
function usage() {
cat <<EOF
$0 [--archive]
EOF
}
HARNESSES=(nextjs)
ARCHIVE=0
ARGS=()
while [ $# -ne 0 ]; do
case "$1" in
--help)
usage
exit 0
;;
--archive)
ARCHIVE=1
;;
*)
ARGS+=("$1")
esac
shift 1
done
function main()
{
for harness in "${HARNESSES[@]}"
do
build "$harness"
if [ "$ARCHIVE" -gt 0 ]; then
archive "$harness"
fi
done
}
function build()
{
local harness="$1"
if [[ ! -d "$harness" ]]; then
echo "harness '${harness}' not found."
fi
local harness_dist_path="./dist/harness-${harness}/"
local harness_src_path="./src/${harness}/"
if [[ -d "$harness_dist_path" ]]; then
rm -rf "$harness_dist_path"
fi
mkdir "$harness_dist_path"
rsync -va "./src/_base/" "$harness_dist_path"
rsync -va "$harness_src_path" "$harness_dist_path"
}
function archive()
{
pushd ./dist >/dev/null
tar -czvf "./harness-$1.tgz" "harness-$1"
rm -rf "./harness-$1"
popd >/dev/null
}
main