Skip to content

Commit 6ff4042

Browse files
committed
Merge pull request dlmanning#159 from laurelnaiad/node-sass-v2
update to node-sass version 2 beta
2 parents f390117 + 12f8db9 commit 6ff4042

File tree

3 files changed

+21
-25
lines changed

3 files changed

+21
-25
lines changed

index.js

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,11 @@ module.exports = function (options) {
2222
}
2323

2424
if (file.sourceMap) {
25-
opts.sourceComments = 'map';
2625
opts.sourceMap = file.path;
2726
}
2827

29-
if (opts.sourceComments === 'map' || opts.sourceComments === 'normal') {
30-
opts.sourceMap = opts.sourceMap || '';
31-
opts.file = file.path;
32-
} else {
33-
opts.data = file.contents.toString();
34-
}
28+
opts.data = file.contents.toString();
29+
opts.file = file.path;
3530

3631
if (opts.includePaths && Array.isArray(opts.includePaths)) {
3732
if (opts.includePaths.indexOf(fileDir) === -1) {
@@ -41,26 +36,27 @@ module.exports = function (options) {
4136
opts.includePaths = [fileDir];
4237
}
4338

44-
opts.success = function (css, sourceMap) {
45-
if (typeof opts.onSuccess === 'function') opts.onSuccess(css, sourceMap);
39+
opts.success = function (obj) {
40+
if (typeof opts.onSuccess === 'function') opts.onSuccess(obj);
4641

47-
if (sourceMap) {
42+
if (obj.map && obj.map.length || obj.map.version) {
4843
// hack to remove the already added sourceMappingURL from libsass
49-
css = css.replace(/\/\*#\s*sourceMappingURL\=.*\*\//, '');
44+
obj.css = obj.css.replace(/\/\*#\s*sourceMappingURL\=.*\*\//, '');
5045

5146
// libsass gives us sources' paths relative to file;
5247
// gulp-sourcemaps needs sources' paths relative to file.base;
5348
// so alter the sources' paths to please gulp-sourcemaps.
54-
sourceMap = JSON.parse(sourceMap);
55-
sourceMap.sources = sourceMap.sources.map(function(source) {
49+
obj.map = obj.map.version ? obj.map : JSON.parse(sourceMap);
50+
obj.map.sources = obj.map.sources.map(function(source) {
5651
var abs = path.resolve(path.dirname(file.path), source);
5752
return path.relative(file.base, abs);
5853
});
59-
sourceMap = JSON.stringify(sourceMap);
54+
obj.map = JSON.stringify(obj.map);
6055

61-
applySourceMap(file, sourceMap);
56+
applySourceMap(file, obj.map);
6257
}
63-
handleOutput(css, file, cb);
58+
59+
handleOutput(obj, file, cb);
6460
};
6561

6662
opts.error = function (err) {
@@ -80,7 +76,7 @@ module.exports = function (options) {
8076
if ( opts.sync ) {
8177
try {
8278
var output = nodeSass.renderSync(opts);
83-
opts.success(output, null);
79+
opts.success(output);
8480
handleOutput(output, file, cb);
8581
} catch(err) {
8682
opts.error(err);
@@ -96,7 +92,7 @@ module.exports = function (options) {
9692

9793
function handleOutput(output, file, cb) {
9894
file.path = ext(file.path, '.css');
99-
file.contents = new Buffer(output);
95+
file.contents = new Buffer(output.css);
10096
cb(null, file);
10197
}
10298

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121
"url": "https://github.com/dlmanning/gulp-sass/issues"
2222
},
2323
"dependencies": {
24-
"node-sass": "^1.0",
24+
"clone": "~0.1.18",
2525
"gulp-util": "^3.0",
2626
"map-stream": "~0.1",
27-
"vinyl-sourcemaps-apply": "~0.1.1",
28-
"clone": "~0.1.18"
27+
"node-sass": "2.0.0-beta",
28+
"vinyl-sourcemaps-apply": "~0.1.1"
2929
},
3030
"devDependencies": {
3131
"tape": "~2.3",

test/test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ test('emit error on sass errors', function (t) {
131131
new Buffer('body { font \'Comic Sans\'; }'));
132132
stream.on('error', function (err) {
133133
t.equal(err.message,
134-
'stdin:1: property "font" must be followed by a \':\'\n'
134+
'property "font" must be followed by a \':\''
135135
);
136136
t.end();
137137
});
@@ -144,7 +144,7 @@ test('emit error on sass errors when using sync true', function (t) {
144144
new Buffer('body { font \'Comic Sans\'; }'));
145145
stream.on('error', function (err) {
146146
t.equal(err.message,
147-
'stdin:1: property "font" must be followed by a \':\'\n'
147+
'property "font" must be followed by a \':\''
148148
);
149149
t.end();
150150
});
@@ -153,8 +153,8 @@ test('emit error on sass errors when using sync true', function (t) {
153153

154154
test('call custom error callback when opts.onError is given', function (t) {
155155
var stream = gsass({ onError: function (err) {
156-
t.equal(err,
157-
'stdin:1: property "font" must be followed by a \':\'\n'
156+
t.equal(err.message,
157+
'property "font" must be followed by a \':\''
158158
);
159159
t.end();
160160
}});

0 commit comments

Comments
 (0)