Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3cdf1a3

Browse files
committed
Passing file as data
Resolves #158 once I get it working
1 parent d59befe commit 3cdf1a3

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

index.js

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ var PLUGIN_NAME = 'gulp-sass';
1515
var gulpSass = function gulpSass(options, sync) {
1616
return through.obj(function(file, enc, cb) {
1717
var opts,
18+
ip,
1819
filePush,
1920
errorM,
2021
callback,
@@ -31,7 +32,20 @@ var gulpSass = function gulpSass(options, sync) {
3132
}
3233

3334
opts = assign({}, options);
34-
opts.file = file.path;
35+
opts.data = file.contents.toString();
36+
37+
if (opts.includePaths) {
38+
if (typeof opts.includePaths === 'string') {
39+
ip = opts.includePaths;
40+
opts.includePaths = [];
41+
opts.includePaths.push(ip);
42+
}
43+
}
44+
else {
45+
opts.includePaths = [];
46+
}
47+
48+
opts.includePaths.push(path.dirname(file.path));
3549

3650
// Generate Source Maps if plugin source-map present
3751
if (file.sourceMap) {
@@ -58,9 +72,13 @@ var gulpSass = function gulpSass(options, sync) {
5872
// Handles error message
5973
//////////////////////////////
6074
errorM = function errorM(error) {
61-
var relativePath = path.relative(process.cwd(), error.file),
75+
var relativePath = '',
76+
filePath = error.file === 'stdin' ? file.path : error.file,
6277
message = '';
6378

79+
filePath = filePath ? filePath : file.path;
80+
relativePath = path.relative(process.cwd(), filePath);
81+
6482
message += gutil.colors.underline(relativePath) + '\n';
6583
message += gutil.colors.gray(' ' + error.line + ':' + error.column) + ' ';
6684
message += error.message;

0 commit comments

Comments
 (0)