Skip to content

Commit

Permalink
use /bin/sh for pre-commit script for portability
Browse files Browse the repository at this point in the history
  • Loading branch information
wiktorn committed Jun 7, 2024
1 parent 61737c4 commit 0160392
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions tools/pre-commit-tfdoc.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
#!/bin/sh

# Copyright 2024 Google LLC
#
Expand All @@ -16,19 +16,16 @@

set -e

SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
SCRIPT_DIR=$(dirname -- "$(readlink -f -- "$0")")

files=("$@")
declare -A directories

for file in "${files[@]}"; do
dir=$(dirname "${file}")
for file in "$@"; do
if [ -d "${file}" ]; then
dir="${file}"
else
dir=$(dirname "${file}")
fi
if [ -f "${dir}/README.md" ] && [ -f "${dir}/main.tf" ]; then
directories["${dir}"]=1
echo "${dir}"
fi
done

for dir in "${!directories[@]}"; do # iterate over keys in directories
echo python "${SCRIPT_DIR}/tfdoc.py" "${dir}"
python "${SCRIPT_DIR}/tfdoc.py" "${dir}"
done
done | sort | uniq | xargs -I {} /bin/sh -c "echo python \"${SCRIPT_DIR}/tfdoc.py\" {} ; python \"${SCRIPT_DIR}/tfdoc.py\" {}"

0 comments on commit 0160392

Please sign in to comment.