Skip to content

Commit

Permalink
changes to match changes in node-sass api
Browse files Browse the repository at this point in the history
  • Loading branch information
dgbeck committed Apr 5, 2015
1 parent 88df23b commit 2085d57
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,31 @@ module.exports = function( file, opts ) {
var data = "";
if( file !== undefined && path.extname( file ) !== ".scss" )
return through();
else
else {
return through( write, end );
}

function write(buf) {
data += buf;
}

function end() {
try {
opts = opts ? opts : {};
var includePaths = opts.includePaths;
var pathToAdd = [path.dirname(file)];
opts.includePaths = Array.isArray(includePaths) ?
includePaths.concat(pathToAdd) :
var sassOpts = {};

sassOpts.data = data;

var pathToAdd = [ path.dirname( file ) ];
sassOpts.includePaths = Array.isArray( opts && opts.includePaths ) ?
opts.includePaths.concat( pathToAdd ) :
pathToAdd;
this.queue( sass.renderSync( data, opts ) );

var result = sass.renderSync( sassOpts );
if( result instanceof Error ) {
throw result;
}

this.queue( result.css );
} catch( err ) {
this.emit( 'error', new Error( err ) );
}
Expand Down

0 comments on commit 2085d57

Please sign in to comment.