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:
$((cat $filePath) | dayone new)
Here's what I've got for the nodejs side. The dayone command does work but there is nothing piped into it.
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) => {
console.log(error, stdout, stderr);
});
terminal.stdin.end();
Thanks for any help!