title: Node js child process delete multiple files
body: <p>I'm trying to set up a node.js child process to delete multiple files via the terminal. This works when deleting one file - but fails when I supply an array of files.</p>
  
  <pre><code>const spawnSync = require('child_process').spawnSync;
  
  var toDelete = array.join(' ');
  
    if (toDelete.length) {    
      spawnSync('rm', ['-rf', toDelete ]);
    }
  </code></pre>
  
  <p>which I thought would end up being sent as <strong>rm -rf data/foo.txt data/bar.txt</strong> (which works on when I type it into the terminal)</p>
  
  <p>...however, I must be doing it wrong.</p>