11#! /usr/bin/env bash
22
3- # Runs "appendEnvironmentVariable.sh" for every script file in the current directory and its sub directories.
3+ # Runs "appendEnvironmentVariables.sh" for every script file in all directories and subdirectories.
4+ # Note: This script can be run from any directory (e.g. the repository root). It changes to the repository root internally.
45
5- # Requires appendEnvironmentVariable .sh
6+ # Requires appendEnvironmentVariables .sh
67
78# Fail on any error ("-e" = exit on first error, "-o pipefail" exist on errors within piped commands)
89set -o errexit -o pipefail
910
10- # # Get this "scripts" directory if not already set
11+ # # Get this "scripts/documentation " directory if not already set
1112# Even if $BASH_SOURCE is made for Bourne-like shells it is also supported by others and therefore here the preferred solution.
1213# CDPATH reduces the scope of the cd command to potentially prevent unintended directory changes.
1314# This way non-standard tools like readlink aren't needed.
1415DOCUMENTATION_SCRIPTS_DIR=${DOCUMENTATION_SCRIPTS_DIR:- $( CDPATH=. cd -- " $( dirname -- " ${BASH_SOURCE[0]} " ) " && pwd -P )} # Repository directory containing the documentation generation scripts
15- echo " generateEnvironmentVariablesReference : DOCUMENTATION_SCRIPTS_DIR=${DOCUMENTATION_SCRIPTS_DIR} "
16+ echo " generateEnvironmentVariableReference : DOCUMENTATION_SCRIPTS_DIR=${DOCUMENTATION_SCRIPTS_DIR} "
1617
17- echo " generateEnvironmentVariableReference: Generating ENVIRONMENT_VARIABLES.md..."
18+ # Change to the repository root so that the output file is written there and all relative paths work correctly
19+ cd " ${DOCUMENTATION_SCRIPTS_DIR} /../.."
20+
21+ echo " generateEnvironmentVariableReference: Generating scripts/ENVIRONMENT_VARIABLES.md..."
1822
1923# Clear existing markdown document
20- source " ${DOCUMENTATION_SCRIPTS_DIR} /appendEnvironmentVariables.sh" " clear" || exit 1
24+ source " ${DOCUMENTATION_SCRIPTS_DIR} /appendEnvironmentVariables.sh" " clear" " scripts/ENVIRONMENT_VARIABLES.md " || exit 1
2125
22- # Loop through all script files in the current directory
26+ # Loop through all script files in all directories from the repository root
2327find . -type f -name " *.sh" | sort | while read -r scriptFile; do
24- echo " generateEnvironmentVariablesReference : Searching for environment variables in ${scriptFile} "
25- source " ${DOCUMENTATION_SCRIPTS_DIR} /appendEnvironmentVariables.sh" " ${scriptFile} " || exit 1
28+ echo " generateEnvironmentVariableReference : Searching for environment variables in ${scriptFile} "
29+ source " ${DOCUMENTATION_SCRIPTS_DIR} /appendEnvironmentVariables.sh" " ${scriptFile} " " scripts/ENVIRONMENT_VARIABLES.md " || exit 1
2630done
2731
2832echo " generateEnvironmentVariableReference: Successfully generated ENVIRONMENT_VARIABLES.md."
0 commit comments