title: How to zip only the html files in a folder having different extensions using nodejs
body: <p>I have a folder which has got files with many extensions like html and txt. I need to zip only the html files in that folder. </p>
  
  <p>I tried like - </p>
  
  <pre><code>const archiver = require("archiver");
  const fs = require("fs");
  
  function zipDirectory(source, out) {
      const archive = archiver("zip", { zlib: { level: 9 } });
      const stream = fs.createWriteStream(out);
  
      return new Promise((resolve, reject) =&gt; {
        archive
          .directory(source, false)
          .on("error", err =&gt; reject(err))
          .pipe(stream);
  
        stream.on("close", () =&gt; resolve());
        archive.finalize();
      });
    }
  
  
    zipDirectory('./sample/*.html', 'sam.zip');
  </code></pre>
  
  <p>But didnt work. How can I zip only the files with extension HTML alone. Please help</p>