-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathresetAndScanChanged.sh
More file actions
executable file
·32 lines (24 loc) · 1.67 KB
/
resetAndScanChanged.sh
File metadata and controls
executable file
·32 lines (24 loc) · 1.67 KB
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
#!/usr/bin/env bash
# Executes "resetAndScan.sh" only if "detectChangedFiles.sh" returns detected changes.
# Note: "resetAndScan" expects jQAssistant to be installed in the "tools" directory.
# Requires resetAndScan.sh, scanTypescript.sh, detectChangedFiles.sh, findPathsToScan.sh
# Fail on any error ("-e" = exit on first error, "-o pipefail" exist on errors within piped commands)
set -o errexit -o pipefail
## Get this "scripts" directory if not already set
# Even if $BASH_SOURCE is made for Bourne-like shells it is also supported by others and therefore here the preferred solution.
# CDPATH reduces the scope of the cd command to potentially prevent unintended directory changes.
# This way non-standard tools like readlink aren't needed.
SCRIPTS_DIR=${SCRIPTS_DIR:-$( CDPATH=. cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P )} # Repository directory containing the shell scripts
echo "resetAndScanChanged SCRIPTS_DIR=${SCRIPTS_DIR}"
# Prepare scan
source "${SCRIPTS_DIR}/scanTypescript.sh"
filesAndDirectoriesToScan=$( source "${SCRIPTS_DIR}/findPathsToScan.sh" )
# Scan and analyze Artifacts when they were changed
changeDetectionReturnCode=$( source "${SCRIPTS_DIR}/detectChangedFiles.sh" --readonly --paths "${filesAndDirectoriesToScan}")
if [[ "${changeDetectionReturnCode}" == "0" ]] ; then
echo "resetAndScanChanged: Artifacts unchanged. Scan skipped."
else
echo "resetAndScanChanged: Detected change (${changeDetectionReturnCode}). Resetting database and scanning artifacts."
source "${SCRIPTS_DIR}/resetAndScan.sh" "${filesAndDirectoriesToScan}"
changeDetectionReturnCode=$( source "${SCRIPTS_DIR}/detectChangedFiles.sh" --paths "${filesAndDirectoriesToScan}")
fi