Skip to content

Commit f6bd8d7

Browse files
run_add copied
1 parent 0db6aba commit f6bd8d7

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

projects/default/run_add.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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" "$@"

0 commit comments

Comments
 (0)