@ -30,28 +30,28 @@ exports.setLogger = function(newLogger) {
exports . getProcessed = function ( filename ) {
exports . getProcessed = function ( filename ) {
try {
try {
logger . debug ( "Processing File %s" , filename ) ;
logger . debug ( "Processing File %s" , filename ) ;
var extension = utils . getExtension ( filename ) ;
var extension = utils . getExtension ( filename ) ; // use the utils function to get the files extension
var data = null ;
var data = null ;
if ( caching . isCached ( filename ) ) return caching . getCached ( filename )
if ( caching . isCached ( filename ) ) return caching . getCached ( filename ) // return the cached file if it exists
logger . debug ( "File is not cached. Processing..." ) ;
logger . debug ( "File is not cached. Processing..." ) ;
switch ( pp _config [ extension ] ) {
switch ( pp _config [ extension ] ) {
case "sass" :
case "sass" :
logger . debug ( "Processing sass %s" , filename ) ;
logger . debug ( "Processing sass %s" , filename ) ;
data = Buffer . from ( pp _sass . renderSync ( {
data = Buffer . from ( pp _sass . renderSync ( { // use the sass preprocessor
file : filename
file : filename
} ) . css ) . toString ( "utf-8" ) ;
} ) . css ) . toString ( "utf-8" ) ;
break ;
break ;
case "html" :
case "html" :
logger . debug ( "Processing html %s" , filename ) ;
logger . debug ( "Processing html %s" , filename ) ;
data = pp _html . formatHtml ( filename ) ;
data = pp _html . formatHtml ( filename ) ; // use the html-preprocessor
break ;
break ;
default :
default :
logger . debug ( "No processor found for %s. Returning data." , filename ) ;
logger . debug ( "No processor found for %s. Returning data." , filename ) ;
return fs . readFileSync ( filename ) ;
return fs . readFileSync ( filename ) ; // just read the data from the file
}
}
caching . cache ( filename , data ) ;
caching . cache ( filename , data ) ; // cache the file for faster access next time
logger . debug ( "Cached file %s" , filename ) ;
logger . debug ( "Cached file %s" , filename ) ;
return data ;
return data ; // return the data
} catch ( error ) {
} catch ( error ) {
logger . error ( error ) ;
logger . error ( error ) ;
return "Processing Error" ;
return "Processing Error" ;