File tree Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ # Function to find the project root directory
4+ find_project_root () {
5+ local dir=" $( cd " ${1:- $(pwd)} " && pwd) " # Convert to absolute path
6+ local root_files=(" README.md" " LICENSE" " CONTRIBUTE.md" " CNAME" )
7+
8+ while [[ " $dir " != " /" ]]; do
9+ for file in " ${root_files[@]} " ; do
10+ if [[ -f " $dir /$file " ]]; then
11+ echo " $dir " # Return the directory as the project root
12+ return 0
13+ fi
14+ done
15+ dir=$( dirname " $dir " ) # Move one level up
16+ done
17+
18+ return 1 # Return error if no root found
19+ }
20+
21+ # Find the project root directory
22+ project_root=$( find_project_root " $( dirname " ${BASH_SOURCE[0]} " ) " )
23+
24+ # Check if the project root was found
25+ if [[ -z " $project_root " ]]; then
26+ echo " Error: Could not find the project root."
27+ exit 1
28+ fi
29+
30+ # Append the scripts directory to the root path
31+ scripts_dir=" $project_root /scripts"
32+
33+ # Print the final scripts directory for verification
34+ echo " Scripts directory path: $scripts_dir "
35+
36+ # Check if the add.sh script exists in the scripts directory
37+ if [[ ! -f " $scripts_dir /add.sh" ]]; then
38+ echo " Error: add.sh not found in $scripts_dir "
39+ exit 1
40+ fi
41+
42+ # Run the add.sh script with the passed arguments
43+ " $scripts_dir /add.sh" " $@ "
You can’t perform that action at this time.
0 commit comments