title: How to check if path is a directory or file?
body: <p>I want to check if the path is a file or a directory. If it's a directory then Log the directory and file separately. Later I want to send them as json object. </p>
  
  <pre><code>const testFolder = './data/';
  fs.readdir(testFolder, (err, files) =&gt; {
    files.forEach(file =&gt; {
      console.log(`FILES: ${file}`);
    })});
  </code></pre>
  
  <p><strong>Edit:</strong>
  If I try to this</p>
  
  <pre><code>fs.readdir(testFolder, (err, files) =&gt; {
    files.forEach(file =&gt; {
      if (fs.statSync(file).isDirectory()) {
      console.log(`DIR: ${file}`);
    } else {
      console.log(`FILE: ${file}`)
    }
    })}); 
  </code></pre>
  
  <p>I get this error: </p>
  
  <blockquote>
    <p>nodejs binding.lstat(pathModule._makeLong(path))</p>
  </blockquote>
  
  <p><strong>Update:</strong> Found the solution. I had to add testFolder + file like this :</p>
  
  <pre><code>if (fs.statSync(testFolder + file).isDirectory()) {
  </code></pre>