Nodejs criam árvores a partir de diretórios

const { readdirSync } = require("fs");
const { join } = require("path");

const createTreeFromDirectories = (path) => {
	return readdirSync(path, { withFileTypes: true }).reduce((tree, branch) => {
		if (branch.isDirectory()) tree[branch.name] = createTreeFromDirectories(join(path, branch.name));
		return tree;
	}, {});
};

createTreeFromDirectories(process.cwd());
Kind Kinkajou