github.com/mssola/todo@v0.0.0-20181029153210-d25348dc3f48/script/sass (about) 1 #!/bin/bash 2 # Copyright (C) 2014-2017 Miquel Sabaté Solà 3 # 4 # This Source Code Form is subject to the terms of the Mozilla Public 5 # License, v. 2.0. If a copy of the MPL was not distributed with this 6 # file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 8 dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 9 cssdir="$dir/../public/stylesheets" 10 11 # On deploy, execute once and exit. 12 if [ "$TODO_DEPLOY" = "1" ]; then 13 set -e 14 sass --update "$cssdir" 15 exit 0 16 fi 17 18 # Launch a background job that deal with Sass. 19 20 # Get pidfile. 21 todo="/tmp/todo" 22 mkdir -p $todo 23 pidfile="$todo/assets.pid" 24 touch $pidfile 25 26 # Kill off old processes 27 while read pid; do 28 kill $pid > /dev/null 2>&1; 29 done < $pidfile 30 31 # Truncate the PID file 32 > $pidfile 33 34 # If the user just wanted to stop all old processes, then exit here. 35 if [[ $1 == "stop" ]]; then 36 exit 1 37 fi 38 39 # SASS 40 csslog="$todo/sass.log" 41 sass --watch "$cssdir" > $csslog 2>&1 & 42 echo $! >> $pidfile