#!/usr/bin/env bash # Optional tee of deploy output to a log file under the project root. # Args: project_root log_to_dir_relative (empty = skip) deploy_script_tee_log_if_requested() { local project_root="${1:?}" local log_to_dir="${2:-}" if [[ -z "$log_to_dir" ]]; then return 0 fi mkdir -p "${project_root}/${log_to_dir}" local log_file log_file="${project_root}/${log_to_dir}/deploy_$(date +%Y%m%d_%H%M%S).log" info "[deploy] Teeing output to ${log_file}" exec > >(tee "$log_file") }