#!/bin/sh

export project=$HOME/projects/trendplays

watch() {
	npx browser-sync start --proxy 'trendplays.test' -w --files $project/resources &
	pid=$!
	sass --load-path=sass --watch --error-css $project/resources/scss:$project/public &
	pid="$pid $!"
	trap "kill -TERM $pid" 0 1 2 15
	find $project/resources/js -type f | entr -n node build.js &
	pid="$pid $!"
	trap "kill -TERM $pid" 0 1 2 15
	wait
}

once() {
	sass --load-path=sass $project/resources/scss/main.scss $project/public/main.css
}

deploy() {
	rsync -av --delete onyeka assets view files onyeka@onyeka.ca:~/site/
}

case $1 in
	'watch') watch ;;
	'once') once ;;
	'deploy') deploy ;;
esac
