Skip to content

Commit

Permalink
fix(script): only cd into scripts directory if scripts are defined (#335
Browse files Browse the repository at this point in the history
)
  • Loading branch information
xynydev authored Sep 19, 2024
1 parent bd1ff5d commit c80bbcf
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions modules/script/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@ set -euo pipefail
get_yaml_array SCRIPTS '.scripts[]' "$1"
get_yaml_array SNIPPETS '.snippets[]' "$1"

cd "$CONFIG_DIRECTORY/scripts"
# Make every script executable
find "$PWD" -type f -exec chmod +x {} \;
for SCRIPT in "${SCRIPTS[@]}"; do
echo "Running script $SCRIPT"
"$PWD/$SCRIPT"
done
# shellcheck disable=SC2153
if [[ ${#SCRIPTS[@]} -gt 0 ]]; then
cd "$CONFIG_DIRECTORY/scripts"
# Make every script executable
find "$PWD" -type f -exec chmod +x {} \;
for SCRIPT in "${SCRIPTS[@]}"; do
echo "Running script $SCRIPT"
"$PWD/$SCRIPT"
done
fi

# shellcheck disable=SC2153
for SNIPPET in "${SNIPPETS[@]}"; do
echo "Running snippet $SNIPPET"
bash -c "$SNIPPET"
Expand Down

0 comments on commit c80bbcf

Please sign in to comment.