Closed shijianjian closed 5 years ago
Hi, you should be able to write a recursive function that only keeps items with children
.
@shijianjian:
const _ = require('lodash');
const dirTree = require("directory-tree");
const removeFiles = (children) => {
return _.filter(children, child => {
if (child.children) child.children = removeFiles(child.children);
return child.type !== "file"
});
};
const tree = dirTree("some_path");
tree.children = removeFiles(tree.children);
Hi,
Thank you for the pretty simple plugin.
In my application, I care about the folder structure only. I therefore do not want to include the final files. Is there a easy way to select?
For example, I am now getting:
While, what I want is:
I wish to filter the files out.