{"id":18290532,"url":"https://github.com/react-doc/node-directory-tree-md","last_synced_at":"2025-07-11T01:09:15.103Z","repository":{"id":57212311,"uuid":"114870189","full_name":"react-doc/node-directory-tree-md","owner":"react-doc","description":"Convert a directory tree to a JS object, Support Mardown configuration.","archived":false,"fork":false,"pushed_at":"2017-12-28T18:32:51.000Z","size":21,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-13T20:17:28.016Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/react-doc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-12-20T09:45:22.000Z","updated_at":"2020-06-07T05:20:37.000Z","dependencies_parsed_at":"2022-09-03T10:50:59.922Z","dependency_job_id":null,"html_url":"https://github.com/react-doc/node-directory-tree-md","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/react-doc/node-directory-tree-md","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/react-doc%2Fnode-directory-tree-md","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/react-doc%2Fnode-directory-tree-md/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/react-doc%2Fnode-directory-tree-md/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/react-doc%2Fnode-directory-tree-md/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/react-doc","download_url":"https://codeload.github.com/react-doc/node-directory-tree-md/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/react-doc%2Fnode-directory-tree-md/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264703159,"owners_count":23651907,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-05T14:11:21.313Z","updated_at":"2025-07-11T01:09:15.084Z","avatar_url":"https://github.com/react-doc.png","language":"JavaScript","readme":"# node-directory-tree-md \n\n[![Build Status](https://travis-ci.org/uiw-react/node-directory-tree-md.svg)](https://travis-ci.org/uiw-react/node-directory-tree-md)\n\n\u003e A variation of [node-directory-tree](https://github.com/mihneadb/node-directory-tree)\n\nCreates a JavaScript object representing a directory tree.\n\n## Install\n```bash\n$ npm i directory-tree-md\n```\n\n## Usage\n\nMarkdown directory is generated.\n\n```js\nconst dirTree = require('node-directory-tree-md');\nconst tree = dirTree('/some/path', {\n  mdconf: true, // Whether to return Markdown configuration.\n  extensions: /\\.md/,\n});\n```\n\nMarkdown configuration set by comments, support [yaml](http://www.yaml.org/).\n\n```markdown\n\u003c!--\ntitle: Layout \nheder: 😆😆😆😆\ndes: A detailed description\n  header: \n    url: http://google.com\n--\u003e\n\nOther Markdown content\n```\n\n`node-directory-tree-md` will return this JS object:\n\n```json\n{\n  \"path\": \"/some/path\",\n  \"name\": \"doc\",\n  \"children\": [\n    {\n      \"path\": \"/some/path/README.md\",\n      \"name\": \"README.md\",\n      \"relative\": \"/README.md\",\n      \"mdconf\": {\n        \"title\": \"Layout\",\n        \"heder\": \"😆😆😆😆\",\n        \"des\": \"A detailed description\",\n        \"header\": {\n          \"url\": \"http://google.com\"\n        }\n      },\n      \"isEmpty\": true, \n      \"size\": 23,\n      \"extension\": \".md\",\n      \"type\": \"file\"\n    },\n    {\n      \"path\": \"/some/path/doc/layout.en.md\",\n      \"name\": \"layout.en.md\",\n      \"relative\": \"/doc/layout.en.md\",\n      \"mdconf\": {\n        \"title\": \"Layout\"\n      },\n      \"size\": 285,\n      \"extension\": \".md\",\n      \"type\": \"file\"\n    }\n  ],\n  \"size\": 2607,\n  \"type\": \"directory\"\n}\n```\n\nAnd you can also filter by an extensions regex:\nThis is useful for including only certain types of files.\n\n```js\nconst dirTree = require('node-directory-tree-md');\nconst filteredTree = dirTree('/some/path', {extensions:/\\.txt/});\n```\n\nYou can also exclude paths from the tree using a regex:\n\n```js\nconst dirTree = require('node-directory-tree-md');\nconst filteredTree = dirTree('/some/path', {exclude:/some_path_to_exclude/});\n```\n\nA callback function can be executed with each file that matches the extensions provided:\n\n```js\nconst PATH = require('path');\nconst dirTree = require('node-directory-tree-md');\n\nconst tree = dirTree('./test/test_data', {extensions:/\\.txt$/}, (item, PATH) =\u003e {\n\tconsole.log(item);\n});\n```\n\nThe callback function takes the directory item (has path, name, size, and extension) and an instance of [node path](https://nodejs.org/api/path.html).\n\n## Result\nGiven a directory structured like this:\n\n```\nphotos\n├── summer\n│   └── june\n│       └── windsurf.jpg\n└── winter\n    └── january\n        ├── ski.png\n        └── snowboard.jpg\n```\n\n`node-directory-tree-md` will return this JS object:\n\n```json\n{\n  \"path\": \"photos\",\n  \"name\": \"photos\",\n  \"size\": 600,\n  \"type\": \"directory\",\n  \"children\": [\n    {\n      \"path\": \"photos/summer\",\n      \"name\": \"summer\",\n      \"size\": 400,\n      \"type\": \"directory\",\n      \"children\": [\n        {\n          \"path\": \"photos/summer/june\",\n          \"name\": \"june\",\n          \"size\": 400,\n          \"type\": \"directory\",\n          \"children\": [\n            {\n              \"path\": \"photos/summer/june/windsurf.jpg\",\n              \"name\": \"windsurf.jpg\",\n              \"size\": 400,\n              \"type\": \"file\",\n              \"extension\": \".jpg\"\n            }\n          ]\n        }\n      ]\n    },\n    {\n      \"path\": \"photos/winter\",\n      \"name\": \"winter\",\n      \"size\": 200,\n      \"type\": \"directory\",\n      \"children\": [\n        {\n          \"path\": \"photos/winter/january\",\n          \"name\": \"january\",\n          \"size\": 200,\n          \"type\": \"directory\",\n          \"children\": [\n            {\n              \"path\": \"photos/winter/january/ski.png\",\n              \"name\": \"ski.png\",\n              \"size\": 100,\n              \"type\": \"file\",\n              \"extension\": \".png\"\n            },\n            {\n              \"path\": \"photos/winter/january/snowboard.jpg\",\n              \"name\": \"snowboard.jpg\",\n              \"size\": 100,\n              \"type\": \"file\",\n              \"extension\": \".jpg\"\n            }\n          ]\n        }\n      ]\n    }\n  ]\n}\n```\n## Note\nDevice, FIFO and socket files are ignored.\n\nFiles to which the user does not have permissions are included in the directory\ntree, however, directories to which the user does not have permissions, along\nwith all of its contained files, are completely ignored.\n\n## Dev\n\nTo run tests go the package root in your CLI and run,\n\n```bash\n$ npm test\n```\n\nMake sure you have the dev dependencies installed (e.g. `npm install .`)\n\n## Node version\n\nThis project requires at least Node v4.2.\nCheck out version `0.1.1` if you need support for older versions of Node.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freact-doc%2Fnode-directory-tree-md","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Freact-doc%2Fnode-directory-tree-md","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freact-doc%2Fnode-directory-tree-md/lists"}