1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

really enforce binary for exec node stdout when required.

This commit is contained in:
dceejay 2015-01-08 12:35:42 +00:00
parent 4fb2a44d74
commit 92b393d3df
2 changed files with 3 additions and 2 deletions

View File

@ -42,6 +42,7 @@
<p>Optionally can use spawn() instead, which returns output from stdout and stderr as the command runs (ie one line at a time). On completion it then returns a return code (on the 3rd output).</p>
<p>Spawn only expect one command word, with all extra parameters to be comma separated and passed as the append.</p>
<p>The optional append gets added to the command after the <b>msg.payload</b> - so you can do things like pipe the result to another command.</p>
<p>If stdout is binary a <i>buffer</i> is returned - otherwise returns a <i>string</i>.</p>
</script>
<script type="text/javascript">

View File

@ -66,8 +66,8 @@ module.exports = function(RED) {
else {
var cl = node.cmd+" "+msg.payload+" "+node.append;
if (RED.settings.verbose) { node.log(cl); }
var child = exec(cl, {encoding: 'binary'}, function (error, stdout, stderr) {
msg.payload = new Buffer(stdout);
var child = exec(cl, {encoding: 'binary', maxBuffer:10000000}, function (error, stdout, stderr) {
msg.payload = new Buffer(stdout,"binary");
if (isUtf8(msg.payload)) { msg.payload = msg.payload.toString(); }
var msg2 = {payload:stderr};
var msg3 = null;