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 vibe.core.log; 32 33 34 /** 35 * 36 */ 37 class SassException : Exception { 38 39 /** 40 * 41 */ 42 this ( string src ) { 43 super( "Sass: failed to compile " ~ src ); 44 } 45 46 } 47 48 49 /** 50 * 51 */ 52 void compileSass ( string dir, string target ) { 53 auto css = dir ~ target ~ ".css"; 54 auto src = dir ~ target ~ ".scss"; 55 56 logInfo( "Sass: compiling %s -> %s", src, css ); 57 auto cmd = "sass --force " ~ src ~ " " ~ css; 58 auto status = system( cmd ); 59 if ( status != 0 ) { 60 throw new SassException( src ); 61 } 62 }