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*
sass_context* ctx = (sass_context*) cptr;
ctx->source_string = CreateString(options->Get(NanNew("data")));
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.output_style = options->Get(NanNew("style"))->Int32Value();
ctx->options.source_comments = source_comments = options->Get(NanNew("comments"))->BooleanValue();
......
var watch = require('node-watch'),
var watch = require('node-watch'),
render = require('./render'),
path = require('path'),
Emitter = require('events').EventEmitter,
......@@ -49,6 +49,11 @@ var yargs = require('yargs')
type: 'boolean',
alias: 'x'
})
.options('indented-syntax', {
describe: 'Treat data from stdin as sass code (versus scss)',
type: 'boolean',
alias: 'i'
})
.options('help', {
describe: 'Print usage info',
type: 'string',
......@@ -93,13 +98,7 @@ function run(options, emitter) {
options.sourceComments = options.sourceComments[0];
}
if (options.sourceComments === 'map' && !options.sourceMap) {
options.sourceMap = true;
}
if (options.sourceMap) {
options.sourceComments = 'map';
if (options.sourceMap === true) {
options.sourceMap = options.dest + '.map';
} else {
......@@ -140,6 +139,7 @@ module.exports = function(args) {
imagePath: argv['image-path'],
includePaths: argv['include-path'],
omitSourceMapUrl: argv['omit-source-map-url'],
indentedSyntax: argv['indented-syntax'],
outputStyle: argv['output-style'],
precision: argv.precision,
sourceComments: argv['source-comments'],
......
......@@ -7,6 +7,7 @@ function render(options, emitter) {
imagePath: options.imagePath,
includePaths: options.includePaths,
omitSourceMapUrl: options.omitSourceMapUrl,
indentedSyntax: options.indentedSyntax,
outFile: options.outFile,
outputStyle: options.outputStyle,
precision: options.precision,
......
Subproject commit 859d11d53b9bf5d9bf63d861a547222c0f485cd9
Subproject commit 27d4fcd92db501d0662696f08942f35499717f53
......@@ -83,6 +83,7 @@ var prepareOptions = function (options) {
style: SASS_OUTPUT_STYLE[options.output_style || options.outputStyle] || 0,
comments: SASS_SOURCE_COMMENTS[sourceComments] || false,
omitSourceMapUrl: options.omitSourceMapUrl,
indentedSyntax: options.indentedSyntax,
stats: stats,
sourceMap: sourceMap,
precision: parseInt(options.precision) || 5,
......
......@@ -64,6 +64,17 @@ describe('cli', function() {
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) {
var env = assign(process.env, { isTTY: true });
exec('node ' + cliPath, {
......@@ -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