forked from aws-samples/aws-serverless-ecommerce-platform
-
Notifications
You must be signed in to change notification settings - Fork 0
/
clean
executable file
·57 lines (47 loc) · 981 Bytes
/
clean
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
#!/bin/bash
set -e
ROOT=${ROOT:-$(pwd)}
SERVICE=$1
service_dir=$ROOT/$SERVICE
build_dir=$service_dir/build
display_usage () {
echo "Usage: $0 TYPE SERVICE"
}
# Check if there are at least 2 arguments
if [ $# -lt 1 ]; then
display_usage
exit 1
fi
# Check if the service exists
if [ ! -f $service_dir/metadata.yaml ]; then
echo "Service $SERVICE does not exist"
exit 1
fi
# Check for quiet mode
if [ ! -z $QUIET ]; then
export OUTPUT_FILE=$(mktemp)
exec 5>&1 6>&2 1>$OUTPUT_FILE 2>&1
fi
cleanup () {
CODE=$?
if [ ! -z $QUIET ]; then
if [ ! $CODE -eq 0 ]; then
cat $OUTPUT_FILE >&5
fi
rm $OUTPUT_FILE
fi
}
trap cleanup EXIT
clean () {
if [ -z $build_dir ]; then
echo "\$build_dir not set. Aborting"
exit 1
fi
if [ -d $build_dir ]; then
echo "Removing $build_dir"
rm -r $build_dir
else
echo "$build_dir does not exist. Skipping"
fi
}
clean