Categories
JavaScript Answers

How to glob for pattern excluding multiple files with Node.js?

Spread the love

To glob for pattern excluding multiple files with Node.js, we set the ignore property.

For instance, we write

const glob = require("glob");

glob(
  "**/*",
  { ignore: ["index.html", "js", "js/app.js", "js/lib.js"] },
  (err, files) => {
    console.log(files);
  }
);

to call glob with an object with the ignore property to ignore the patterns listed in the array.

And then we get the results from files.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published.