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

Fix output buffer is imcomplete working in child_process #1834

Merged
merged 9 commits into from
Dec 13, 2016
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions bin/node-sass
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ var Emitter = require('events').EventEmitter,
glob = require('glob'),
sass = require('../lib'),
render = require('../lib/render'),
stdout = require('stdout-stream'),
stdin = require('get-stdin'),
fs = require('fs');

Expand Down Expand Up @@ -160,15 +161,7 @@ function getEmitter() {
}
});

emitter.on('log', function(data) {
console.log(data);
});

emitter.on('done', function() {
if (!options.watch && !options.directory) {
process.exit();
}
});
emitter.on('log', stdout.write.bind(stdout));

return emitter;
}
Expand Down
13 changes: 1 addition & 12 deletions lib/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,14 @@ module.exports = function(options, emitter) {
var stdin = options.stdin;

var success = function(result) {
var todo = 1;
var done = function() {
if (--todo <= 0) {
emitter.emit('done');
}
};

if (!destination || stdin) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The done still needs to be fired. It's used in other places. Please undo these changes and just remove

emitter.on('done', function() {		
    // noop		
});

emitter.emit('log', result.css.toString());

if (sourceMap && !options.sourceMapEmbed) {
emitter.emit('log', result.map.toString());
}

return done();
return;
}

emitter.emit('warn', chalk.green('Rendering Complete, saving .css file...'));
Expand All @@ -78,13 +71,10 @@ module.exports = function(options, emitter) {

emitter.emit('warn', chalk.green('Wrote CSS to ' + destination));
emitter.emit('write', err, destination, result.css.toString());
done();
});
});

if (sourceMap) {
todo++;

mkdirp(path.dirname(sourceMap), function(err) {
if (err) {
return emitter.emit('error', chalk.red(err));
Expand All @@ -96,7 +86,6 @@ module.exports = function(options, emitter) {

emitter.emit('warn', chalk.green('Wrote Source Map to ' + sourceMap));
emitter.emit('write-source-map', err, sourceMap, result.map);
done();
});
});
}
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@
"node-gyp": "^3.3.1",
"npmlog": "^4.0.0",
"request": "^2.61.0",
"sass-graph": "^2.1.1"
"sass-graph": "^2.1.1",
"stdout-stream": "^1.4.0"
},
"devDependencies": {
"coveralls": "^2.11.8",
Expand Down