Skip to content

Commit

Permalink
demos: extract some of run_scripts.sh to a function
Browse files Browse the repository at this point in the history
This allows `run_scripts.sh | pager` to work.
  • Loading branch information
ilyagr committed Sep 10, 2023
1 parent e0e90d5 commit bf7c6d3
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion demos/run_scripts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,19 @@ GIT_CONFIG_GLOBAL=$(mktemp --tmpdir gitconfig-XXXX)
export GIT_CONFIG_GLOBAL
git_config "$GIT_CONFIG_GLOBAL"

for script in "$@"; do
run_script_through_term_transcript_and_pipe_result_to_stderr() {
script="$1"
script_base="${script%.sh}"
script_base="${script_base#demo_}"
# We use `term-transcript capture` instead of `term-transcript exec` so that
# we can show the output of the script via `tee`.
(bash "$script" || (echo "SCRIPT FAILED WITH EXIT CODE $?"; false)) 2>&1 | \
tee /dev/stderr | \
term-transcript capture --no-inputs --pure-svg --out "$script_base".svg "$script_base"
}

for script in "$@"; do
run_script_through_term_transcript_and_pipe_result_to_stderr "$script" 2>&1
# Resize to 700 width and any height
which convert > /dev/null \
&& convert -resize 700x10000 -colors 50 -background black \
Expand Down

0 comments on commit bf7c6d3

Please sign in to comment.