Skip to content

Run

FieldValue
TypeSkill Resource
Source~/.copilot/skills/go-task/templates/scripts/run.sh
DescriptionNot specified

Source Content

#!/usr/bin/env bash
#
# run.sh — start this project in development or production mode, auto-detecting
# the stack from the files in the working directory. Wired to `task dev` and
# `task prod` so every repo starts the same way regardless of language.
#
# Usage: run.sh [development|production]
# Honors: DRY_RUN=1 print the command instead of executing it (tests / CI)
set -euo pipefail
MODE="${1:-development}"
case "$MODE" in
development | production) ;;
*)
echo "run.sh: mode must be 'development' or 'production' (got '$MODE')" >&2
exit 2
;;
esac
export APP_ENV="$MODE"
# Execute a command, replacing this shell so signals reach the app directly.
# Under DRY_RUN it prints the command instead, which keeps the script testable.
run() {
if [ "${DRY_RUN:-0}" = "1" ]; then
printf '[dry-run] %s\n' "$*"
return 0
fi
exec "$@"
}
if [ -f go.mod ]; then
if [ "$MODE" = "production" ]; then run go run -tags prod .; else run go run .; fi
elif [ -f package.json ]; then
if [ "$MODE" = "production" ]; then run npm run start; else run npm run dev; fi
elif [ -f Cargo.toml ]; then
if [ "$MODE" = "production" ]; then run cargo run --release; else run cargo run; fi
elif [ -f pyproject.toml ] || [ -f requirements.txt ]; then
run python3 main.py
else
echo "run.sh: no recognized project here (looked for go.mod, package.json, Cargo.toml, pyproject.toml)" >&2
exit 1
fi