Tuesday, April 8, 2025

if you see something (build finished) say something

 Sometimes our build process take a minute, so I had Co-Pilot help build me a script to use the mac's text to speech to announce when it looks like we were ready to go:

#!/bin/bash

# Check if at least one argument is provided
if [ $# -lt 1 ]; then
  echo "Usage: $0 <nx_command> [args...]"
  exit 1
fi

# Build the nx command from the provided arguments
nx_command="$@"
log_file="nx_command.log"

# Run the command in the background and capture its PID
$nx_command &> $log_file &
pid=$!

# Monitor the log file for the specific line
tail -f $log_file | while read line; do
  echo "$line"
  if [[ "$line" == *"All remotes started"* ]]; then
    say "ready"
    break
  fi
done

# Wait for the nx command to finish
wait $pid


No comments:

Post a Comment