Skip to content

Commit

Permalink
Passing file as data
Browse files Browse the repository at this point in the history
Resolves dlmanning#158 once I get it working
  • Loading branch information
Snugug committed Mar 31, 2015
1 parent d59befe commit 3cdf1a3
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ var PLUGIN_NAME = 'gulp-sass';
var gulpSass = function gulpSass(options, sync) {
return through.obj(function(file, enc, cb) {
var opts,
ip,
filePush,
errorM,
callback,
Expand All @@ -31,7 +32,20 @@ var gulpSass = function gulpSass(options, sync) {
}

opts = assign({}, options);
opts.file = file.path;
opts.data = file.contents.toString();

if (opts.includePaths) {
if (typeof opts.includePaths === 'string') {
ip = opts.includePaths;
opts.includePaths = [];
opts.includePaths.push(ip);
}
}
else {
opts.includePaths = [];
}

opts.includePaths.push(path.dirname(file.path));

// Generate Source Maps if plugin source-map present
if (file.sourceMap) {
Expand All @@ -58,9 +72,13 @@ var gulpSass = function gulpSass(options, sync) {
// Handles error message
//////////////////////////////
errorM = function errorM(error) {
var relativePath = path.relative(process.cwd(), error.file),
var relativePath = '',
filePath = error.file === 'stdin' ? file.path : error.file,
message = '';

filePath = filePath ? filePath : file.path;
relativePath = path.relative(process.cwd(), filePath);

message += gutil.colors.underline(relativePath) + '\n';
message += gutil.colors.gray(' ' + error.line + ':' + error.column) + ' ';
message += error.message;
Expand Down

0 comments on commit 3cdf1a3

Please sign in to comment.