From 3cdf1a325dca5f7ac7d9f6150d74d16dee780950 Mon Sep 17 00:00:00 2001 From: Sam Richard Date: Tue, 31 Mar 2015 15:55:26 -0400 Subject: [PATCH] Passing file as data Resolves dlmanning/gulp-sass#158 once I get it working --- index.js | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index fd9cf8a..1e32f00 100644 --- a/index.js +++ b/index.js @@ -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, @@ -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) { @@ -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;