How to pass STDIN to node.js child process
<p>I'm using a library that wraps <code>pandoc</code> for node. But I can't figure out how to pass STDIN to the child process `execFile...</p>

<pre><code>var execFile = require('child_process').execFile;
var optipng = require('pandoc-bin').path;

// STDIN SHOULD GO HERE!
execFile(optipng, ['--from=markdown', '--to=html'], function (err, stdout, stderr) {
    console.log(err);
    console.log(stdout);
    console.log(stderr);
});
</code></pre>

<p>On the CLI it would look like this:</p>

<pre><code>echo "# Hello World" | pandoc -f markdown -t html
</code></pre>

<p><strong>UPDATE 1</strong></p>

<p>Trying to get it working with <code>spawn</code>:</p>

<pre><code>var cp = require('child_process');
var optipng = require('pandoc-bin').path;
var child = cp.spawn(optipng, ['--from=markdown', '--to=html'], { stdio: [ 0, 'pipe', 'pipe' ] });

child.stdin.write('# HELLO');
// then what?
</code></pre>