Skip to content

Instantly share code, notes, and snippets.

@sakuemon
Created September 19, 2013 12:49
Show Gist options
  • Save sakuemon/6622965 to your computer and use it in GitHub Desktop.
Save sakuemon/6622965 to your computer and use it in GitHub Desktop.
gruntでexpressを起動すると文字化けするのを解消 ref: http://qiita.com/TsuyoshiMIYAMOTO/items/f7cf071f47b7190f7b01
var child = spawn(cmd, args, opts.opts);
var stdout = [];
var stdoutLength = 0;
var stderr = [];
var stderrLength = 0;
if (child.stdout) {
child.stdout.on('data', function(buf) {
stdout.push(buf);
stdoutLength += buf.length;
});
}
if (child.stderr) {
child.stderr.on('data', function(buf) {
stderr.push(buf);
stderrLength += buf.length;
});
}
child.on('close', function(code) {
var so = Buffer.concat(stdout, stdoutLength);
var se = Buffer.concat(stderr, stderrLength);
callDone(code, so.toString(), se.toString());
});
return child;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment