File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -7,37 +7,7 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
77
88# Source all library files
99source " $SCRIPT_DIR /lib/sanitize.sh"
10-
11- # Colors for output
12- RED=' \033[0;31m'
13- GREEN=' \033[0;32m'
14- YELLOW=' \033[1;33m'
15- BLUE=' \033[0;34m'
16- ORANGE=' \033[0;33m'
17- NC=' \033[0m' # No Color
18-
19- # Logging functions
20- log_debug () {
21- if [[ " ${DEBUG:- false} " == " true" ]]; then
22- echo -e " ${ORANGE} [DEBUG]${NC} $1 "
23- fi
24- }
25-
26- log_info () {
27- echo -e " ${BLUE} [INFO]${NC} $1 "
28- }
29-
30- log_success () {
31- echo -e " ${GREEN} [SUCCESS]${NC} $1 "
32- }
33-
34- log_warning () {
35- echo -e " ${YELLOW} [WARNING]${NC} $1 "
36- }
37-
38- log_error () {
39- echo -e " ${RED} [ERROR]${NC} $1 "
40- }
10+ source " $SCRIPT_DIR /lib/common.sh"
4111
4212# Validate required environment variables
4313validate_env () {
@@ -1788,14 +1758,6 @@ insert_sbom_data() {
17881758# Global variable for temp directory (so cleanup can access it)
17891759temp_dir=" "
17901760
1791- # Cleanup function
1792- cleanup () {
1793- if [[ -n " $temp_dir " && -d " $temp_dir " ]]; then
1794- log_info " Cleaning up temporary files"
1795- rm -rf " $temp_dir "
1796- fi
1797- }
1798-
17991761# Main function
18001762main () {
18011763 log_info " Starting ClickBOM GitHub Action for SBOM processing"
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ # Common utilities used across all modules
3+
4+ # Colors for output
5+ RED=' \033[0;31m'
6+ GREEN=' \033[0;32m'
7+ YELLOW=' \033[1;33m'
8+ BLUE=' \033[0;34m'
9+ ORANGE=' \033[0;33m'
10+ NC=' \033[0m' # No Color
11+
12+ # Logging functions
13+ log_debug () {
14+ if [[ " ${DEBUG:- false} " == " true" ]]; then
15+ echo -e " ${ORANGE} [DEBUG]${NC} $1 "
16+ fi
17+ }
18+
19+ log_info () {
20+ echo -e " ${BLUE} [INFO]${NC} $1 "
21+ }
22+
23+ log_success () {
24+ echo -e " ${GREEN} [SUCCESS]${NC} $1 "
25+ }
26+
27+ log_warning () {
28+ echo -e " ${YELLOW} [WARNING]${NC} $1 "
29+ }
30+
31+ log_error () {
32+ echo -e " ${RED} [ERROR]${NC} $1 "
33+ }
34+
35+ # Cleanup function
36+ cleanup () {
37+ if [[ -n " $temp_dir " && -d " $temp_dir " ]]; then
38+ log_info " Cleaning up temporary files"
39+ rm -rf " $temp_dir "
40+ fi
41+ }
Original file line number Diff line number Diff line change @@ -15,8 +15,9 @@ setup() {
1515 # Extract only the functions from entrypoint.sh (everything before main function call)
1616 sed ' /^# Run main function/,$d' " $PROJECT_ROOT /entrypoint.sh" > " $TEST_SCRIPT "
1717
18- # Fix the lib/sanitize.sh source path in the extracted script
18+ # Replace the source line in the extracted script
1919 sed -i " s|source \"\$ SCRIPT_DIR/lib/sanitize.sh\" |source \" $PROJECT_ROOT /lib/sanitize.sh\" |" " $TEST_SCRIPT "
20+ sed -i " s|source \"\$ SCRIPT_DIR/lib/common.sh\" |source \" $PROJECT_ROOT /lib/common.sh\" |" " $TEST_SCRIPT "
2021
2122 # Source the functions
2223 source " $TEST_SCRIPT "
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ setup() {
1818
1919 # Replace the source line in the extracted script
2020 sed -i " s|source \"\$ SCRIPT_DIR/lib/sanitize.sh\" |source \" $PROJECT_ROOT /lib/sanitize.sh\" |" " $TEST_SCRIPT "
21+ sed -i " s|source \"\$ SCRIPT_DIR/lib/common.sh\" |source \" $PROJECT_ROOT /lib/common.sh\" |" " $TEST_SCRIPT "
2122
2223 # Source the functions
2324 source " $TEST_SCRIPT "
You can’t perform that action at this time.
0 commit comments