title: Executing a shell script with interactions with child_processes in nodeJS
body: <p>I am building a small custom node CLI application with user input using <a href="https://www.npmjs.com/package/inquirer" rel="nofollow noreferrer">Inquirer</a> and when after a specific chain of inputs, I would like to execute a script that has itself interactions as well. Right now I use the <code>child_processes.exec()</code> function to execute the command, which does work, however my terminal does not render the program and ends up stuck.</p>
  <p>This code executes the external shell script:</p>
  <pre class="lang-js prettyprint-override"><code>cp.exec(
  'svg-inliner', 
  {
   cwd: iconsFolder, 
  }, 
  (err, stdout, stderr) =&gt; {
      if(err) throw err;
      if(stderr) {
        //...
         throw stderr;
      }
       if(stdout) return;
  });
  </code></pre>
  <p><a href="https://i.stack.imgur.com/43Eji.png" rel="nofollow noreferrer">What it should do</a></p>
  <p><a href="https://i.stack.imgur.com/vbPM2.png" rel="nofollow noreferrer">What it currently does</a></p>
  <p>Inquirer executes a callback once all the questions are answered from the termminal. Inside that callback I trigger a function that calls on the <code>child_processes.exec()</code>.</p>
  <pre class="lang-js prettyprint-override"><code>inquirer.prompt(questions)
      .then(answers =&gt; {
        cp.exec();
      }
  </code></pre>
  <p>Is it actually possible to execute another CLI script from a Node.js CLI application?</p>
  <p>Edit:</p>
  <p>I created a <code>.sh</code> file that does what I wanted the exec to do. In that file I execute the node script followed by the svg-inliner command at works wonders.</p>
  <pre class="lang-sh prettyprint-override"><code>node .index.js $1
  
  svg-inliner
  </code></pre>