Pipe a javascript variable into shell command with nodejs
<p>I'm working on a nodejs application and I need to pipe a multi-line string into a shell command. I'm not a pro at shell scripting but if I run this command in my terminal it works just fine:</p>

<p><code>$((cat $filePath) | dayone new)</code></p>

<p>Here's what I've got for the nodejs side. The dayone command does work but there is nothing piped into it.</p>

<pre><code>const cp = require('child_process');
const terminal = cp.spawn('bash');

var multiLineVariable = 'Multi\nline\nstring';

terminal.stdin.write('mul');
cp.exec('dayone new', (error, stdout, stderr) =&gt; {
    console.log(error, stdout, stderr);
});
terminal.stdin.end();
</code></pre>

<p>Thanks for any help!</p>