Commit 79c6eb93 by Adeel Mujahid

Merge pull request #727 from am11/master

Code: Improvements
parents a0691b1b 730a1341
......@@ -130,11 +130,11 @@ function getSourceMap(options) {
function getOptions(options, cb) {
options = options || {};
options.comments = options.sourceComments || false;
options.sourceComments = options.sourceComments || false;
options.data = options.data || null;
options.file = options.file || null;
options.outFile = getOutFile(options);
options.paths = (options.includePaths || []).join(path.delimiter);
options.includePaths = (options.includePaths || []).join(path.delimiter);
options.precision = parseInt(options.precision) || 5;
options.sourceMap = getSourceMap(options);
options.style = getStyle(options) || 0;
......@@ -142,34 +142,6 @@ function getOptions(options, cb) {
// context object represents node-sass environment
options.context = { options: options, callback: cb };
// options.error and options.success are for libsass binding
options.error = function(err) {
var payload = util._extend(new Error(), JSON.parse(err));
if (cb) {
options.context.callback.call(options.context, payload, null);
}
};
options.success = function() {
var result = options.result;
var stats = endStats(result.stats);
var payload = {
css: result.css,
map: result.map,
stats: stats
};
if (cb) {
options.context.callback.call(options.context, null, payload);
}
};
delete options.include_paths;
delete options.includePaths;
delete options.source_comments;
delete options.sourceComments;
options.result = {
stats: getStats(options)
};
......@@ -193,6 +165,29 @@ var binding = require(getBinding());
module.exports.render = function(options, cb) {
options = getOptions(options, cb);
// options.error and options.success are for libsass binding
options.error = function(err) {
var payload = util._extend(new Error(), JSON.parse(err));
if (cb) {
options.context.callback.call(options.context, payload, null);
}
};
options.success = function() {
var result = options.result;
var stats = endStats(result.stats);
var payload = {
css: result.css,
map: result.map,
stats: stats
};
if (cb) {
options.context.callback.call(options.context, null, payload);
}
};
var importer = options.importer;
if (importer) {
......
......@@ -153,12 +153,12 @@ void extract_options(Local<Object> options, void* cptr, sass_context_wrapper* ct
sass_option_set_output_path(sass_options, create_string(options->Get(NanNew("outFile"))));
sass_option_set_output_style(sass_options, (Sass_Output_Style)options->Get(NanNew("style"))->Int32Value());
sass_option_set_is_indented_syntax_src(sass_options, options->Get(NanNew("indentedSyntax"))->BooleanValue());
sass_option_set_source_comments(sass_options, options->Get(NanNew("comments"))->BooleanValue());
sass_option_set_source_comments(sass_options, options->Get(NanNew("sourceComments"))->BooleanValue());
sass_option_set_omit_source_map_url(sass_options, options->Get(NanNew("omitSourceMapUrl"))->BooleanValue());
sass_option_set_source_map_embed(sass_options, options->Get(NanNew("sourceMapEmbed"))->BooleanValue());
sass_option_set_source_map_contents(sass_options, options->Get(NanNew("sourceMapContents"))->BooleanValue());
sass_option_set_source_map_file(sass_options, create_string(options->Get(NanNew("sourceMap"))));
sass_option_set_include_path(sass_options, create_string(options->Get(NanNew("paths"))));
sass_option_set_include_path(sass_options, create_string(options->Get(NanNew("includePaths"))));
sass_option_set_precision(sass_options, options->Get(NanNew("precision"))->Int32Value());
}
......
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