-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathclean-slate.sh
71 lines (59 loc) · 1.89 KB
/
clean-slate.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
#!/bin/bash
########################################################################################
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: MIT-0
########################################################################################
#
# @function usage
#
function usage() {
echo -e "
------------------------------------------------------------------------------
This script helps to clean up files and directories created by build script
------------------------------------------------------------------------------
bash ./clean-slate.sh [--path <root-path>]
where
--path <root-path> [optional] specify the root directory to start cleaning.
"
return 0
}
ROOTDIR=
while [[ $# -gt 0 ]]; do
key="$1"
case $key in
-p|--path)
ROOTDIR="$2"
shift # past key
shift # past value
;;
*)
shift
;;
esac
done
[ -z "$ROOTDIR" ] && \
ROOTDIR="."
function clean_deployment() {
echo "------------------------------------------------------------------------------"
echo "Cleaning deployment folder"
echo "------------------------------------------------------------------------------"
local startDir=$1
for dir in "global-s3-assets" "regional-s3-assets" "open-source"; do
find "${startDir}" -name "${dir}" -type d -exec rm -rfv "{}" \;
done
}
function clean_source() {
echo "------------------------------------------------------------------------------"
echo "Cleaning source folder"
echo "------------------------------------------------------------------------------"
local startDir=$1
for dir in "node_modules" "dist"; do
find "${startDir}" -name "${dir}" -type d -exec rm -rfv "{}" \;
done
for file in "package-lock.json" ".DS_Store"; do
find "${startDir}" -name "${file}" -type f -exec rm -rfv "{}" \;
done
}
usage
clean_deployment "${ROOTDIR}"
clean_source "${ROOTDIR}"