WIP MIL-007: fetch the framework's qc, follow links, default configuration files
- git submodule update --init --recursive after adding or reusing the framework - Follow links to the script so SCRIPT_DIR and the checkout are the real ones - config.env and .env: --config/--env, else ./ in the working folder, else the checkout's - Name the files used; a file from the working folder needs a yes before any request - MIL-007 accepted; test fixtures for the qc checklists; tests/test-launch.sh Work in progress: the README section is not written yet, and four tests of test-launch.sh fail and two shellcheck warnings remain; they are fixed next. Task: MIL-007#1 Task: MIL-007#2 Refs #47 Refs #48 Refs #51
This commit is contained in:
+31
-9
@@ -86,18 +86,39 @@ if ((BASH_VERSINFO[0] < 4 || (BASH_VERSINFO[0] == 4 && BASH_VERSINFO[1] < 4)));
|
||||
fi
|
||||
|
||||
# Where this script lives; the library files and the project root are found
|
||||
# from here, never from the current directory.
|
||||
readonly SCRIPT_FILE="${BASH_SOURCE[0]}"
|
||||
case "${BASH_SOURCE[0]}" in
|
||||
*/*) script_path_dir="${BASH_SOURCE[0]%/*}" ;;
|
||||
# from here, never from the current directory. A link to the script (a
|
||||
# command in a folder on PATH) is followed to the real file, however many
|
||||
# links lie on the way; readlink without -f exists on Linux, macOS and Git
|
||||
# Bash alike.
|
||||
script_path="${BASH_SOURCE[0]}"
|
||||
script_link_count=0
|
||||
while [[ -L $script_path ]]; do
|
||||
((++script_link_count <= 40)) || {
|
||||
printf 'error: too many links when following %s\n' "${BASH_SOURCE[0]}" >&2
|
||||
exit 1
|
||||
}
|
||||
script_link_target="$(readlink -- "$script_path")"
|
||||
case "$script_link_target" in
|
||||
/*) script_path="$script_link_target" ;;
|
||||
*)
|
||||
case "$script_path" in
|
||||
*/*) script_path="${script_path%/*}/$script_link_target" ;;
|
||||
*) script_path="$script_link_target" ;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
done
|
||||
readonly SCRIPT_FILE="$script_path"
|
||||
case "$script_path" in
|
||||
*/*) script_path_dir="${script_path%/*}" ;;
|
||||
*) script_path_dir="." ;;
|
||||
esac
|
||||
SCRIPT_DIR="$(cd "$script_path_dir" && pwd)"
|
||||
SCRIPT_DIR="$(cd -P "$script_path_dir" && pwd -P)"
|
||||
readonly SCRIPT_DIR
|
||||
unset script_path_dir
|
||||
# The script lives in src/; the configuration files live one level up, in
|
||||
# the project root, next to config.env.example and .env.example.
|
||||
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
||||
unset script_path script_path_dir script_link_count script_link_target
|
||||
# The script lives in src/; the checkout is one level up, next to
|
||||
# config.env.example and .env.example.
|
||||
PROJECT_ROOT="$(cd -P "$SCRIPT_DIR/.." && pwd -P)"
|
||||
readonly PROJECT_ROOT
|
||||
|
||||
# shellcheck source=lib/constants.sh
|
||||
@@ -163,6 +184,7 @@ main() {
|
||||
trap finish EXIT
|
||||
is_valid_repo_name "$PROJECT_NAME" ||
|
||||
die "REPOFOUNDRY_NAME is not a valid project name"
|
||||
WORKING_FOLDER="$(pwd -P)"
|
||||
parse_args "$@"
|
||||
check_tools
|
||||
setup_temp_dir
|
||||
|
||||
Reference in New Issue
Block a user