Created
September 19, 2013 12:49
-
-
Save sakuemon/6622965 to your computer and use it in GitHub Desktop.
gruntでexpressを起動すると文字化けするのを解消 ref: http://qiita.com/TsuyoshiMIYAMOTO/items/f7cf071f47b7190f7b01
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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