Commit d58c303c by Adeel

Options: Adds options for source-maps varieties.

Also fixes the issue with destination path
being resolved w.r.t input, without accounting
for it being already absolute.
parent 9f7a78d8
...@@ -31,6 +31,8 @@ var cli = meow({ ...@@ -31,6 +31,8 @@ var cli = meow({
' --output-style CSS output style (nested|expanded|compact|compressed)', ' --output-style CSS output style (nested|expanded|compact|compressed)',
' --source-comments Include debug info in output', ' --source-comments Include debug info in output',
' --source-map Emit source map', ' --source-map Emit source map',
' --source-map-embed Embed sourceMappingUrl as data URI',
' --source-map-contents Embed include contents in map',
' --include-path Path to look for imported files', ' --include-path Path to look for imported files',
' --image-path Path to prepend when using the `image-url()` helper', ' --image-path Path to prepend when using the `image-url()` helper',
' --precision The amount of precision allowed in decimal numbers', ' --precision The amount of precision allowed in decimal numbers',
...@@ -43,6 +45,8 @@ var cli = meow({ ...@@ -43,6 +45,8 @@ var cli = meow({
'omit-source-map-url', 'omit-source-map-url',
'recursive', 'recursive',
'stdout', 'stdout',
'source-map-embed',
'source-map-contents',
'source-comments' 'source-comments'
], ],
string: [ string: [
...@@ -116,7 +120,17 @@ function getOptions(args, options) { ...@@ -116,7 +120,17 @@ function getOptions(args, options) {
var dir = options.output || process.cwd(); var dir = options.output || process.cwd();
options.src = args[0]; options.src = args[0];
options.dest = args[1] ? path.join(dir, args[1]) : null; options.dest = null;
if (args[1]) { // destination is available
// now first check if the destination is absolute path
// see http://stackoverflow.com/a/24225816/863980 for Marc Diethelm's comment
if (path.resolve(args[1]) === path.normalize(args[1]).replace(/(.+)([\/|\\])$/, '$1')) {
options.dest = args[1];
} else { // since dest path is relative, resolve it w.r.t input
options.dest = path.join(dir, args[1]);
}
}
if (!options.dest && !options.stdout) { if (!options.dest && !options.stdout) {
var ext = path.extname(options.src); var ext = path.extname(options.src);
......
...@@ -20,6 +20,8 @@ module.exports = function(options, emitter) { ...@@ -20,6 +20,8 @@ module.exports = function(options, emitter) {
outputStyle: options.outputStyle, outputStyle: options.outputStyle,
precision: options.precision, precision: options.precision,
sourceComments: options.sourceComments, sourceComments: options.sourceComments,
sourceMapEmbed: options.sourceMapEmbed,
sourceMapContents: options.sourceMapContents,
sourceMap: options.sourceMap sourceMap: options.sourceMap
}; };
...@@ -46,7 +48,7 @@ module.exports = function(options, emitter) { ...@@ -46,7 +48,7 @@ module.exports = function(options, emitter) {
fs.writeFile(options.dest, css, function(err) { fs.writeFile(options.dest, css, function(err) {
if (err) { if (err) {
return emitter.emit('error', chalk.red('Error: ' + err)); return emitter.emit('error', chalk.red(err));
} }
emitter.emit('warn', chalk.green('Wrote CSS to ' + options.dest)); emitter.emit('warn', chalk.green('Wrote CSS to ' + options.dest));
......
...@@ -45,6 +45,8 @@ void ExtractOptions(Local<Object> options, void* cptr, sass_context_wrapper* ctx ...@@ -45,6 +45,8 @@ void ExtractOptions(Local<Object> options, void* cptr, sass_context_wrapper* ctx
sass_option_set_is_indented_syntax_src(sass_options, options->Get(NanNew("indentedSyntax"))->BooleanValue()); 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("comments"))->BooleanValue());
sass_option_set_omit_source_map_url(sass_options, options->Get(NanNew("omitSourceMapUrl"))->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, CreateString(options->Get(NanNew("sourceMap")))); sass_option_set_source_map_file(sass_options, CreateString(options->Get(NanNew("sourceMap"))));
sass_option_set_include_path(sass_options, CreateString(options->Get(NanNew("paths")))); sass_option_set_include_path(sass_options, CreateString(options->Get(NanNew("paths"))));
sass_option_set_precision(sass_options, options->Get(NanNew("precision"))->Int32Value()); 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