title: Javascript,Nodejs: search for a specific word string in files
body: <p>i'm trying to make an app that searches for all files 
  contains a specified string under the current directory/subdirectory.</p>
  
  <p>as i understand it means i need to create a read stream, loop it, load the read data to an array, if the word found give __filename, dirname and if ! not found message.</p>
  
  <p>unfortunately, i could not make it work...
  any clue?</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-js lang-js prettyprint-override"><code>var path = require('path'),
   fs=require('fs');
  
  function fromDir(startPath,filter,ext){
  
      if (!fs.existsSync(startPath)){
          console.log("no dir ",startPath);
          return;
      };
      
      var files=fs.readdirSync(startPath);
      let found = files.find((file) =&gt; {
          let thisFilename = path.join(startPath, file);
          let stat = fs.lstatSync(thisFilename);
          var readStream = fs.createReadStream(fs);
          var readline = require('readline');
          if (stat.isDirectory()) {
              fromDir(thisFilename, filename,readline, ext);
  
  
  
          } else {
              if (path.extname(createReadStream) === ext &amp;&amp; path.basename(thisFilename, ext) === filename) {
                  return true;
          }
          }
          });
  
         
  
              console.log('-- your word has found on : ',filename,__dirname);
          }
       
      if (!found) { 
          console.log("Sorry, we didn't find your term");
      }
  
      }
      
      fromDir('./', process.argv[3], process.argv[2]);
     </code></pre>
  </div>
  </div>
  </p>