1 
2     ////////////////////////////////////////////////////////////////////////////////////////////
3     //  Copyright (c) 2012 Christopher Nicholson-Sauls                                        //
4     //                                                                                        //
5     //  Permission is hereby granted, free of charge, to any person obtaining a copy of this  //
6     //  software and associated documentation files (the "Software"), to deal in the          //
7     //  Software without restriction, including without limitation the rights to use, copy,   //
8     //  modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,   //
9     //  and to permit persons to whom the Software is furnished to do so, subject to the      //
10     //  following conditions:                                                                 //
11     //                                                                                        //
12     //  The above copyright notice and this permission notice shall be included in all        //
13     //  copies or substantial portions of the Software.                                       //
14     //                                                                                        //
15     //  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,   //
16     //  INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A         //
17     //  PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT    //
18     //  HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF  //
19     //  CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE  //
20     //  OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                                         //
21     ////////////////////////////////////////////////////////////////////////////////////////////
22 
23 
24 /**
25  *
26  */
27 module sass;
28 
29 import std.process;
30 
31 import std.file : exists;
32 
33 import vibe.core.log;
34 
35 
36 /**
37  *
38  */
39 class SassException : Exception {
40 
41 	/**
42 	 *
43 	 */
44 	this ( string src ) {
45 		super( "Sass: failed to compile " ~ src );
46 	}
47 
48 }
49 
50 
51 /**
52  *
53  */
54 void compileSass ( string dir, string target ) {
55 	auto css = dir ~ target ~ ".css";
56 	auto src = dir ~ target;
57 
58   if( exists( src ~ ".sass" ) )
59     src ~= ".sass";
60   else
61     src ~= ".scss";
62 	
63 	logInfo( "Sass: compiling %s -> %s", src, css );
64 	auto cmd = "sass --force " ~ src ~ " " ~ css;
65 	auto status = system( cmd );
66 	if ( status != 0 ) {
67 		throw new SassException( src );
68 	}
69 }