Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

Commit

Permalink
Merge pull request #166 from LaurentGoderre/revert-render-events
Browse files Browse the repository at this point in the history
Reverted the render events to their original and adapted the test to avoid async race
  • Loading branch information
andrew committed Oct 5, 2013
2 parents 9b99f87 + b77299c commit cb3761e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
10 changes: 6 additions & 4 deletions lib/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ function render(options, emitter) {
if (err) return emitter.emit('error', ('Error: ' + err).red);
emitter.emit('warn', ('Wrote CSS to ' + options.outFile).green);
emitter.emit('write', err, options.outFile, css);
if (options.stdout) {
emitter.emit('log', css);
}
emitter.emit('render', css);
});

if (options.stdout) {
emitter.emit('log', css);
}

emitter.emit('render', css);
},
error: function(error) {
emitter.emit('error', error);
Expand Down
14 changes: 7 additions & 7 deletions test/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,35 +67,35 @@ describe('cli', function() {
path.join(__dirname, 'include_path.scss')
]);
emitter.on('error', done);
emitter.on('render', function(css){
emitter.on('write', function(err, file, css){
assert.equal(css.trim(), 'body {\n background: red;\n color: blue; }');
fs.unlink(path.resolve(process.cwd(), 'include_path.css'), done);
fs.unlink(file, done);
});
});

it('should compile with the --output-style', function(done){
var emitter = cli(['--output-style', 'compressed', path.join(__dirname, 'sample.scss')]);
emitter.on('error', done);
emitter.on('render', function(css){
emitter.on('write', function(err, file, css){
assert.equal(css, expectedSampleCompressed);
fs.unlink(path.resolve(process.cwd(), 'sample.css'), done);
fs.unlink(file, done);
});
});

it('should compile with the --source-comments option', function(done){
var emitter = cli(['--source-comments', 'none', path.join(__dirname, 'sample.scss')]);
emitter.on('error', done);
emitter.on('render', function(css){
emitter.on('write', function(err, file, css){
assert.equal(css, expectedSampleNoComments);
fs.unlink(path.resolve(process.cwd(), 'sample.css'), done);
fs.unlink(file, done);
});
});

it('should write the output to the file specified with the --output option', function(done){
var resultPath = path.join(__dirname, '../output.css');
var emitter = cli(['--output', resultPath, path.join(__dirname, 'sample.scss')]);
emitter.on('error', done);
emitter.on('write', function(css){
emitter.on('write', function(err, file, css){
fs.exists(resultPath, function(exists) {
assert(exists);
fs.unlink(resultPath, done);
Expand Down

0 comments on commit cb3761e

Please sign in to comment.