Commit 173e8280 by Kevin Martensson

Minor readability improvements

parent 2e61a57a
var sass = require('../sass'), var fs = require('fs'),
chalk = require('chalk'), chalk = require('chalk'),
fs = require('fs'); sass = require('../sass');
function render(options, emitter) { /**
* Render
*
* @param {Object} options
* @param {Object} emitter
* @api public
*/
module.exports = function(options, emitter) {
var renderOptions = { var renderOptions = {
imagePath: options.imagePath, imagePath: options.imagePath,
includePaths: options.includePath, includePaths: options.includePath,
...@@ -29,7 +37,7 @@ function render(options, emitter) { ...@@ -29,7 +37,7 @@ function render(options, emitter) {
} }
}; };
if (options.stdout || (!options.dest && (!process.stdout.isTTY || !process.env.isTTY))) { if (options.stdout || (!options.dest && !process.stdout.isTTY)) {
emitter.emit('log', css); emitter.emit('log', css);
return done(); return done();
} }
...@@ -37,7 +45,10 @@ function render(options, emitter) { ...@@ -37,7 +45,10 @@ function render(options, emitter) {
emitter.emit('warn', chalk.green('Rendering Complete, saving .css file...')); emitter.emit('warn', chalk.green('Rendering Complete, saving .css file...'));
fs.writeFile(options.dest, css, function(err) { fs.writeFile(options.dest, css, function(err) {
if (err) { return emitter.emit('error', chalk.red('Error: ' + err)); } if (err) {
return emitter.emit('error', chalk.red('Error: ' + err));
}
emitter.emit('warn', chalk.green('Wrote CSS to ' + options.dest)); emitter.emit('warn', chalk.green('Wrote CSS to ' + options.dest));
emitter.emit('write', err, options.dest, css); emitter.emit('write', err, options.dest, css);
done(); done();
...@@ -45,8 +56,12 @@ function render(options, emitter) { ...@@ -45,8 +56,12 @@ function render(options, emitter) {
if (options.sourceMap) { if (options.sourceMap) {
todo++; todo++;
fs.writeFile(options.sourceMap, sourceMap, function(err) { fs.writeFile(options.sourceMap, sourceMap, function(err) {
if (err) {return emitter.emit('error', chalk.red('Error' + err)); } if (err) {
return emitter.emit('error', chalk.red('Error' + err));
}
emitter.emit('warn', chalk.green('Wrote Source Map to ' + options.sourceMap)); emitter.emit('warn', chalk.green('Wrote Source Map to ' + options.sourceMap));
emitter.emit('write-source-map', err, options.sourceMap, sourceMap); emitter.emit('write-source-map', err, options.sourceMap, sourceMap);
done(); done();
...@@ -61,6 +76,4 @@ function render(options, emitter) { ...@@ -61,6 +76,4 @@ function render(options, emitter) {
}; };
sass.render(renderOptions); sass.render(renderOptions);
} };
module.exports = render;
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