title: giving my little search engine a "no file was found" messenge
body: <p>I have a simple JS code meant to be executed in Node.js for searching all text files in folders and sub folders.</p>
  
  <p>I would like to add a "no files were found" message if no text files exist,
  any ideas?</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>var path = require('path'), fs=require('fs');
  
  function fromDir(startPath,filter){
  
      if (!fs.existsSync(startPath)){
          console.log("no dir ",startPath);
          return;
      }
      var files=fs.readdirSync(startPath);
      for(var i=0;i&lt;files.length;i++){
          var filename=path.join(startPath,files[i]);
          var stat = fs.lstatSync(filename);
          if (stat.isDirectory()){
              fromDir(filename,filter); 
          }
          else if (filename.indexOf(filter)&gt;=0) {
              console.log('-- found: ',filename);
          };
      };
  };
  
  fromDir('../yoyo','.txt');</code></pre>
  </div>
  </div>
  </p>