mihneadb / node-directory-tree

Convert a directory tree to a JS object.
MIT License
523 stars 106 forks source link

unable to exclude a directory #114

Closed arunkumar413 closed 2 years ago

arunkumar413 commented 2 years ago

const tree = dirTree("./", { exclude: "/node_modules" });

This throws an error

   if (excludes.some((exclusion) => exclusion.test(path))) {
                 ^

TypeError: excludes.some is not a function
mihneadb commented 2 years ago

The exclude param is supposed to be a regex.

const dirTree = require("directory-tree");
const filteredTree = dirTree("/some/path", { exclude: /some_path_to_exclude/ });

So try doing:

const tree = dirTree("./", { exclude: /node_modules/ });