forked from przeprogramowani/opanuj-frontend-praktyka
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup-subdirs.sh
More file actions
executable file
·54 lines (47 loc) · 1.43 KB
/
Copy pathsetup-subdirs.sh
File metadata and controls
executable file
·54 lines (47 loc) · 1.43 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/bash
echo "Running custom setup scripts..."
# Configuration for custom script execution
# Add new entries to this array without changing execution logic
CONFIG_JSON='[
{
"directory": "./examples/module4/lesson2/design-tokens",
"script": "setup.sh"
},
{
"directory": "./examples/module1/lesson2/signals-angular-start",
"script": "setup.sh"
},
{
"directory": "./examples/module1/lesson2/signals-angular-finish",
"script": "setup.sh"
}
]'
# Add more configurations by adding entries to the JSON array above
# Store the root directory
ROOT_DIR=$(pwd)
# Loop through each config entry
echo "$CONFIG_JSON" | jq -c '.[]' | while read -r entry; do
DIR=$(echo "$entry" | jq -r '.directory')
SCRIPT=$(echo "$entry" | jq -r '.script')
# Check if this directory exists in the repository
if [ -d "$DIR" ]; then
echo "Executing script: $SCRIPT for directory: $DIR"
# Check if script path is absolute or relative
SCRIPT_PATH="$DIR/$SCRIPT"
if [[ "$SCRIPT" == /* ]]; then
# If script path is absolute, use it directly
SCRIPT_PATH="$SCRIPT"
fi
if [ -f "$SCRIPT_PATH" ]; then
# Navigate to the directory and run the script
cd "$DIR" && bash "$SCRIPT"
# Return to the root directory
cd "$ROOT_DIR"
echo "Returned to root directory"
else
echo "Warning: Script $SCRIPT_PATH not found"
fi
else
echo "Warning: Directory $DIR not found"
fi
done