From 2cd03d15f8c8d8c29daef2efb4406825de8b0b12 Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Tue, 31 May 2016 12:29:41 +0200 Subject: Added the `bin` directory and sorted out licensing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Everything is licensed under the MIT license, except what it's inside of the `bin` directory, which is licensed under the GPLv3+ license. Signed-off-by: Miquel Sabaté Solà --- bin/sass | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 bin/sass (limited to 'bin/sass') diff --git a/bin/sass b/bin/sass new file mode 100644 index 0000000..8e3fc10 --- /dev/null +++ b/bin/sass @@ -0,0 +1,78 @@ +#!/bin/sh +# Copyright (C) 2014-2016 Miquel Sabaté Solà +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Launch a background job that deals with SASS/SCSS. +# +# If no arguments were given, then it will try to kill a previous instance +# of the background job and launch another one. You can prevent the +# re-launching by passing the "stop" argument. This way, this script will +# efectively kill the currently running process and quit. Any other argument +# will be ignored. +# +# Therefore, the usage of this script is as follows: +# +# $ sass [stop] +# + + +## +# Config values. +# +# NOTE: path values should *not* start and/or end with a slash. + +# The base directory. +dir="$( cd "$( dirname "$0" )" && pwd )/.." + +# The absolute path to the directory where we can store temporary files. You +# don't really want to use this default since it can easily clash with other +# projects ;) +tmp="/tmp" + +# The absolute path to the file that will store the PID of the currently +# running background job. +pidfile="$tmp/assets.pid" + +# The absolute path to the SASS log. +csslog="$tmp/sass.log" + +# The absolute path of the directory containing the SASS files. +cssdir="$dir/public/stylesheets" + + +## +# And here starts the script itself. + + +# Get pidfile. +mkdir -p $tmp +touch $pidfile + +# Kill off old processes +while read pid; do + kill $pid > /dev/null 2>&1; +done < $pidfile + +# Truncate the PID file +> $pidfile + +# If the user just wanted to stop all old processes, then exit here. +if [[ $1 == "stop" ]]; then + exit 1 +fi + +# SASS +sass --watch "$cssdir" > $csslog 2>&1 & +echo $! >> $pidfile -- cgit v1.2.3