Commit 67ea9c58 by Adeel

Source-map: Parse as JSON.

parent d58c303c
...@@ -164,6 +164,8 @@ function getOptions(options) { ...@@ -164,6 +164,8 @@ function getOptions(options) {
}; };
options.success = function(css, sourceMap) { options.success = function(css, sourceMap) {
sourceMap = JSON.parse(sourceMap);
endStats(options, sourceMap); endStats(options, sourceMap);
if (success) { if (success) {
...@@ -254,7 +256,7 @@ module.exports.renderSync = function(options) { ...@@ -254,7 +256,7 @@ module.exports.renderSync = function(options) {
options = getOptions(options); options = getOptions(options);
output = options.file ? binding.renderFileSync(options) : binding.renderSync(options); output = options.file ? binding.renderFileSync(options) : binding.renderSync(options);
endStats(options, options.stats.sourceMap); endStats(options, JSON.parse(options.stats.sourceMap));
return output; return output;
}; };
...@@ -296,7 +298,7 @@ module.exports.renderFile = function(options) { ...@@ -296,7 +298,7 @@ module.exports.renderFile = function(options) {
var dir = path.dirname(outFile); var dir = path.dirname(outFile);
var sourceMapFile = path.resolve(dir, options.sourceMap); var sourceMapFile = path.resolve(dir, options.sourceMap);
fs.writeFile(sourceMapFile, sourceMap, function(err) { fs.writeFile(sourceMapFile, JSON.stringify(sourceMap), function(err) {
if (err) { if (err) {
return options.error(err); return options.error(err);
} }
......
...@@ -421,8 +421,7 @@ describe('api', function() { ...@@ -421,8 +421,7 @@ describe('api', function() {
stats: stats, stats: stats,
sourceMap: true, sourceMap: true,
success: function() { success: function() {
var map = JSON.parse(stats.sourceMap); assert.equal(stats.sourceMap.sources[0], 'index.scss');
assert.equal(map.sources[0], 'index.scss');
done(); done();
} }
}); });
...@@ -516,8 +515,7 @@ describe('api', function() { ...@@ -516,8 +515,7 @@ describe('api', function() {
sourceMap: true sourceMap: true
}); });
var map = JSON.parse(stats.sourceMap); assert.equal(stats.sourceMap.sources[0], 'index.scss');
assert.equal(map.sources[0], 'index.scss');
done(); done();
}); });
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment