Commit 0f9ff916 by Andrew Nesbitt

Merge pull request #452 from am11/master

Feature: Supports indented code with stdin or data 
parents da55f452 f8911974
...@@ -65,6 +65,7 @@ void ExtractOptions(Local<Value> optionsValue, void* cptr, sass_context_wrapper* ...@@ -65,6 +65,7 @@ void ExtractOptions(Local<Value> optionsValue, void* cptr, sass_context_wrapper*
sass_context* ctx = (sass_context*) cptr; sass_context* ctx = (sass_context*) cptr;
ctx->source_string = CreateString(options->Get(NanNew("data"))); ctx->source_string = CreateString(options->Get(NanNew("data")));
ctx->output_path = CreateString(options->Get(NanNew("outFile"))); ctx->output_path = CreateString(options->Get(NanNew("outFile")));
ctx->options.is_indented_syntax_src = options->Get(NanNew("indentedSyntax"))->BooleanValue();
ctx->options.image_path = CreateString(options->Get(NanNew("imagePath"))); ctx->options.image_path = CreateString(options->Get(NanNew("imagePath")));
ctx->options.output_style = options->Get(NanNew("style"))->Int32Value(); ctx->options.output_style = options->Get(NanNew("style"))->Int32Value();
ctx->options.source_comments = source_comments = options->Get(NanNew("comments"))->BooleanValue(); ctx->options.source_comments = source_comments = options->Get(NanNew("comments"))->BooleanValue();
......
var watch = require('node-watch'), var watch = require('node-watch'),
render = require('./render'), render = require('./render'),
path = require('path'), path = require('path'),
Emitter = require('events').EventEmitter, Emitter = require('events').EventEmitter,
...@@ -49,6 +49,11 @@ var yargs = require('yargs') ...@@ -49,6 +49,11 @@ var yargs = require('yargs')
type: 'boolean', type: 'boolean',
alias: 'x' alias: 'x'
}) })
.options('indented-syntax', {
describe: 'Treat data from stdin as sass code (versus scss)',
type: 'boolean',
alias: 'i'
})
.options('help', { .options('help', {
describe: 'Print usage info', describe: 'Print usage info',
type: 'string', type: 'string',
...@@ -93,13 +98,7 @@ function run(options, emitter) { ...@@ -93,13 +98,7 @@ function run(options, emitter) {
options.sourceComments = options.sourceComments[0]; options.sourceComments = options.sourceComments[0];
} }
if (options.sourceComments === 'map' && !options.sourceMap) {
options.sourceMap = true;
}
if (options.sourceMap) { if (options.sourceMap) {
options.sourceComments = 'map';
if (options.sourceMap === true) { if (options.sourceMap === true) {
options.sourceMap = options.dest + '.map'; options.sourceMap = options.dest + '.map';
} else { } else {
...@@ -140,6 +139,7 @@ module.exports = function(args) { ...@@ -140,6 +139,7 @@ module.exports = function(args) {
imagePath: argv['image-path'], imagePath: argv['image-path'],
includePaths: argv['include-path'], includePaths: argv['include-path'],
omitSourceMapUrl: argv['omit-source-map-url'], omitSourceMapUrl: argv['omit-source-map-url'],
indentedSyntax: argv['indented-syntax'],
outputStyle: argv['output-style'], outputStyle: argv['output-style'],
precision: argv.precision, precision: argv.precision,
sourceComments: argv['source-comments'], sourceComments: argv['source-comments'],
......
...@@ -7,6 +7,7 @@ function render(options, emitter) { ...@@ -7,6 +7,7 @@ function render(options, emitter) {
imagePath: options.imagePath, imagePath: options.imagePath,
includePaths: options.includePaths, includePaths: options.includePaths,
omitSourceMapUrl: options.omitSourceMapUrl, omitSourceMapUrl: options.omitSourceMapUrl,
indentedSyntax: options.indentedSyntax,
outFile: options.outFile, outFile: options.outFile,
outputStyle: options.outputStyle, outputStyle: options.outputStyle,
precision: options.precision, precision: options.precision,
......
Subproject commit 859d11d53b9bf5d9bf63d861a547222c0f485cd9 Subproject commit 27d4fcd92db501d0662696f08942f35499717f53
...@@ -83,6 +83,7 @@ var prepareOptions = function (options) { ...@@ -83,6 +83,7 @@ var prepareOptions = function (options) {
style: SASS_OUTPUT_STYLE[options.output_style || options.outputStyle] || 0, style: SASS_OUTPUT_STYLE[options.output_style || options.outputStyle] || 0,
comments: SASS_SOURCE_COMMENTS[sourceComments] || false, comments: SASS_SOURCE_COMMENTS[sourceComments] || false,
omitSourceMapUrl: options.omitSourceMapUrl, omitSourceMapUrl: options.omitSourceMapUrl,
indentedSyntax: options.indentedSyntax,
stats: stats, stats: stats,
sourceMap: sourceMap, sourceMap: sourceMap,
precision: parseInt(options.precision) || 5, precision: parseInt(options.precision) || 5,
......
...@@ -64,6 +64,17 @@ describe('cli', function() { ...@@ -64,6 +64,17 @@ describe('cli', function() {
src.pipe(emitter.stdin); src.pipe(emitter.stdin);
}); });
it('should treat data as indented code (.sass) if --indented-syntax flag is used', function(done) {
this.timeout(6000);
var src = fs.createReadStream(path.join(__dirname, 'indented.sass'));
var emitter = spawn(cliPath, ['--stdout', '--indented-syntax']);
// when hit the callback in the following,
// it means that data is recieved, so we are ok to go.
emitter.stdout.on('data', function() { done(); });
src.pipe(emitter.stdin);
});
it('should print help when run with no arguments', function(done) { it('should print help when run with no arguments', function(done) {
var env = assign(process.env, { isTTY: true }); var env = assign(process.env, { isTTY: true });
exec('node ' + cliPath, { exec('node ' + cliPath, {
...@@ -258,4 +269,16 @@ describe('cli', function() { ...@@ -258,4 +269,16 @@ describe('cli', function() {
}); });
}); });
}); });
it('should omit a sourceMappingURL from CSS if --omit-source-map-url flag is used', function(done) {
var emitter = cli([sampleScssPath, '--source-map', path.join(__dirname, '../sample.map'), '--omit-source-map-url']);
emitter.on('error', done);
emitter.on('done', function() {
fs.exists(sampleCssOutputPath, function(exists) {
assert.ok(fs.readFileSync(sampleCssOutputPath, 'utf8').indexOf('sourceMappingURL=') === -1);
if (exists) {fs.unlinkSync(sampleCssOutputPath);}
done();
});
});
});
}); });
foo
+ bar
color: red
Subproject commit a1e8aa6b70101943acd5dd0d48711fa921f7c42c Subproject commit 0882c3093cba708ea419e521fb48a272ab6b8b6d
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