anvil.compass
Advanced tools
Comparing version 0.0.1 to 0.0.2
/* | ||
anvil.compass - Compass plugin for anvil.js | ||
version: 0.0.1 | ||
version: 0.0.2 | ||
author: [object Object] | ||
@@ -96,9 +96,6 @@ copyright: 2012 | ||
// The files from these directories will be excluded from anvil processing | ||
// @TODO: Look at excluding by file extension | ||
file_exclude_dirs: [ | ||
"sass_dir", | ||
"images_dir" | ||
{ "folder": "sass_dir", "pattern": "\\.(sass|scss)$"} | ||
], | ||
commander: [ | ||
[ "-C", "--compass", "run compass compiler"] | ||
], | ||
cfg_file: anvil.config.working + "/compass.config.rb", | ||
@@ -118,3 +115,3 @@ command_args: [ "compile", "." ], | ||
self.parseConfig( content, function() { | ||
self.writeConfigFile( done ); | ||
self.writeConfigFile( content, true, done ); | ||
} ); | ||
@@ -125,3 +122,3 @@ } | ||
} else { | ||
this.writeConfigFile( done ); | ||
this.writeConfigFile( "", false, done ); | ||
} | ||
@@ -181,3 +178,6 @@ | ||
writeConfigFile: function( callback ) { | ||
writeConfigFile: function( prepended_content, resolved_paths_only, callback ) { | ||
prepended_content = prepended_content || ""; | ||
resolved_paths_only = resolved_paths_only || false; | ||
var self = this, | ||
@@ -195,7 +195,22 @@ cfg_lines = [], | ||
"http_fonts_dir" | ||
]; | ||
], | ||
copyToFile = function(val, key) { | ||
var copy = false; | ||
if ( ! _.isNull( val ) && ! _.contains( self.config_exclude_keys, key ) ) { | ||
if ( resolved_paths_only ) { | ||
copy = _.contains( to_resolve, key ); | ||
} else { | ||
copy = true; | ||
} | ||
} | ||
return copy; | ||
}; | ||
if ( prepended_content ) { | ||
cfg_lines.push( prepended_content ); | ||
} | ||
// Prepare config object for writing to Ruby file | ||
_.each( self.config, function(val, key, list) { | ||
if ( ! _.isNull( val ) && ! _.contains( self.config_exclude_keys, key ) ) { | ||
if ( copyToFile( val, key ) ) { | ||
self.config[key] = _.contains( to_resolve, key ) ? resolve_path( val ) : val; | ||
@@ -205,3 +220,3 @@ cfg_lines.push(key + " = " + rubify( self.config[key] ) ); | ||
}); | ||
// Join file lines array into a string for writing to file | ||
@@ -214,6 +229,7 @@ config_contents = cfg_lines.join("\r\n"); | ||
.reject( function( dir ) { | ||
return _.isNull( self.config[ dir ] ); | ||
return _.isNull( self.config[ dir.folder ] ); | ||
} ) | ||
.map( function( dir ) { | ||
return path.resolve( self.config[ dir ] ); | ||
dir.folder = path.resolve( self.config[ dir.folder ] ); | ||
return dir; | ||
}) | ||
@@ -226,4 +242,4 @@ .value(); | ||
// Break build, couldn't create configuration file | ||
anvil.log.error( err ); | ||
anvil.events.raise( "build.stop", "Error creating Compass configuration file" ); | ||
anvil.raise( "log.error", err ); | ||
anvil.raise( "build.stop", "Error creating Compass configuration file" ); | ||
} | ||
@@ -240,4 +256,5 @@ callback(); | ||
_.each( self.file_exclude_dirs, function( dir ) { | ||
if ( startsWith( file.workingPath, dir ) ) { | ||
reject = true; | ||
if ( startsWith( file.workingPath, dir.folder ) ) { | ||
var regex = new RegExp(dir.pattern); | ||
reject = regex.test( file.name ); | ||
} | ||
@@ -265,12 +282,12 @@ }); | ||
compass.on( "exit", function( code ) { | ||
anvil.log.event( "Compass Output" ); | ||
anvil.log.event( "----------------------" ); | ||
anvil.raise( "log.event", "Compass Output" ); | ||
anvil.raise( "log.event", "----------------------" ); | ||
var lines = output.toString().split( /\n/ ); | ||
if ( lines ) { | ||
_.each(lines, function( line ) { | ||
anvil.log.event( line.trim() ); | ||
anvil.raise( "log.event", line.trim() ); | ||
}); | ||
} | ||
anvil.log.event( "----------------------" ); | ||
anvil.log.event( "Compass Compiling Complete" ); | ||
anvil.raise( "log.event", "----------------------" ); | ||
anvil.raise( "log.event", "Compass Compiling Complete" ); | ||
done(); | ||
@@ -277,0 +294,0 @@ }); |
@@ -9,3 +9,3 @@ { | ||
"description": "Compass plugin for anvil.js", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"repository": { | ||
@@ -27,4 +27,4 @@ "type": "git", | ||
"readme": "## Anvil Compass Plugin\n\nThis plugin requires anvil.js version 0.8.* or greater.\n\n## Installation\n\n\tanvil install anvil.compass", | ||
"_id": "anvil.compass@0.0.1", | ||
"_id": "anvil.compass@0.0.2", | ||
"_from": "anvil.compass" | ||
} |
@@ -87,9 +87,6 @@ var cp = require( "child_process" ), | ||
// The files from these directories will be excluded from anvil processing | ||
// @TODO: Look at excluding by file extension | ||
file_exclude_dirs: [ | ||
"sass_dir", | ||
"images_dir" | ||
{ "folder": "sass_dir", "pattern": "\\.(sass|scss)$"} | ||
], | ||
commander: [ | ||
[ "-C", "--compass", "run compass compiler"] | ||
], | ||
cfg_file: anvil.config.working + "/compass.config.rb", | ||
@@ -109,3 +106,3 @@ command_args: [ "compile", "." ], | ||
self.parseConfig( content, function() { | ||
self.writeConfigFile( done ); | ||
self.writeConfigFile( content, true, done ); | ||
} ); | ||
@@ -116,3 +113,3 @@ } | ||
} else { | ||
this.writeConfigFile( done ); | ||
this.writeConfigFile( "", false, done ); | ||
} | ||
@@ -172,3 +169,6 @@ | ||
writeConfigFile: function( callback ) { | ||
writeConfigFile: function( prepended_content, resolved_paths_only, callback ) { | ||
prepended_content = prepended_content || ""; | ||
resolved_paths_only = resolved_paths_only || false; | ||
var self = this, | ||
@@ -186,7 +186,22 @@ cfg_lines = [], | ||
"http_fonts_dir" | ||
]; | ||
], | ||
copyToFile = function(val, key) { | ||
var copy = false; | ||
if ( ! _.isNull( val ) && ! _.contains( self.config_exclude_keys, key ) ) { | ||
if ( resolved_paths_only ) { | ||
copy = _.contains( to_resolve, key ); | ||
} else { | ||
copy = true; | ||
} | ||
} | ||
return copy; | ||
}; | ||
if ( prepended_content ) { | ||
cfg_lines.push( prepended_content ); | ||
} | ||
// Prepare config object for writing to Ruby file | ||
_.each( self.config, function(val, key, list) { | ||
if ( ! _.isNull( val ) && ! _.contains( self.config_exclude_keys, key ) ) { | ||
if ( copyToFile( val, key ) ) { | ||
self.config[key] = _.contains( to_resolve, key ) ? resolve_path( val ) : val; | ||
@@ -196,3 +211,3 @@ cfg_lines.push(key + " = " + rubify( self.config[key] ) ); | ||
}); | ||
// Join file lines array into a string for writing to file | ||
@@ -205,6 +220,7 @@ config_contents = cfg_lines.join("\r\n"); | ||
.reject( function( dir ) { | ||
return _.isNull( self.config[ dir ] ); | ||
return _.isNull( self.config[ dir.folder ] ); | ||
} ) | ||
.map( function( dir ) { | ||
return path.resolve( self.config[ dir ] ); | ||
dir.folder = path.resolve( self.config[ dir.folder ] ); | ||
return dir; | ||
}) | ||
@@ -217,4 +233,4 @@ .value(); | ||
// Break build, couldn't create configuration file | ||
anvil.log.error( err ); | ||
anvil.events.raise( "build.stop", "Error creating Compass configuration file" ); | ||
anvil.raise( "log.error", err ); | ||
anvil.raise( "build.stop", "Error creating Compass configuration file" ); | ||
} | ||
@@ -231,4 +247,5 @@ callback(); | ||
_.each( self.file_exclude_dirs, function( dir ) { | ||
if ( startsWith( file.workingPath, dir ) ) { | ||
reject = true; | ||
if ( startsWith( file.workingPath, dir.folder ) ) { | ||
var regex = new RegExp(dir.pattern); | ||
reject = regex.test( file.name ); | ||
} | ||
@@ -256,12 +273,12 @@ }); | ||
compass.on( "exit", function( code ) { | ||
anvil.log.event( "Compass Output" ); | ||
anvil.log.event( "----------------------" ); | ||
anvil.raise( "log.event", "Compass Output" ); | ||
anvil.raise( "log.event", "----------------------" ); | ||
var lines = output.toString().split( /\n/ ); | ||
if ( lines ) { | ||
_.each(lines, function( line ) { | ||
anvil.log.event( line.trim() ); | ||
anvil.raise( "log.event", line.trim() ); | ||
}); | ||
} | ||
anvil.log.event( "----------------------" ); | ||
anvil.log.event( "Compass Compiling Complete" ); | ||
anvil.raise( "log.event", "----------------------" ); | ||
anvil.raise( "log.event", "Compass Compiling Complete" ); | ||
done(); | ||
@@ -268,0 +285,0 @@ }); |
2
17537
8
523