Skip to content

Commit

Permalink
Check that both scripts are being run from repo root
Browse files Browse the repository at this point in the history
  • Loading branch information
jakcharvat committed Dec 5, 2024
1 parent 4373231 commit 2c5b22f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
14 changes: 11 additions & 3 deletions scripts/new-day.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,26 @@

set -euo pipefail

NC='\033[0m'
BOLD='\033[1m'
GREEN='\033[0;32m'

RED='\033[0;31m'
GREEN='\033[0;32m'
BLUE='\033[0;34m'
GREY='\033[0;90m'
LIGHT_GREY='\033[0;37m'
NC='\033[0m'
GREY='\033[0;90m'

info() { echo -e "${BLUE}$1${NC}"; }
success() { echo -e "\n${GREEN}$1${NC}"; }
error() { echo -e "\n${RED}$1${NC}" >&2; }

repo_root=$(git rev-parse --show-toplevel)
current_dir=$(pwd)
if [ "$repo_root" != "$current_dir" ]; then
error "🏠 Must be run from repository root"
exit 1
fi

if [ $# -ne 1 ] || ! [[ $1 =~ ^[0-9]+$ ]]; then
error "🎅 Ho ho ho! Please provide a day number"
exit 1
Expand Down
12 changes: 11 additions & 1 deletion scripts/next-day.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,21 @@

set -euo pipefail

NC='\033[0m'
BOLD='\033[1m'

RED='\033[0;31m'
BLUE='\033[0;34m'
NC='\033[0m'

info() { echo -e "${BLUE}$1${NC}"; }
error() { echo -e "\n${RED}$1${NC}" >&2; }

repo_root=$(git rev-parse --show-toplevel)
current_dir=$(pwd)
if [ "$repo_root" != "$current_dir" ]; then
error "🏠 Must be run from repository root"
exit 1
fi

info "🔍 Finding next day to create..."
next_day=$(ls -d day* 2>/dev/null | sort -V | tail -n1 | sed 's/day0*//' || echo 0)
Expand Down

0 comments on commit 2c5b22f

Please sign in to comment.