{"id":13403023,"url":"https://github.com/yangshun/tree-node-cli","last_synced_at":"2025-04-12T23:33:41.960Z","repository":{"id":32423831,"uuid":"132988209","full_name":"yangshun/tree-node-cli","owner":"yangshun","description":"🌲 Node.js library to list the contents of directories in a tree-like format, similar to the Linux tree command","archived":false,"fork":false,"pushed_at":"2024-12-05T15:02:29.000Z","size":238,"stargazers_count":253,"open_issues_count":4,"forks_count":29,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-12T23:33:39.420Z","etag":null,"topics":["cli","directory","file","hacktoberfest","linux","node","tree"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yangshun.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2018-05-11T04:13:43.000Z","updated_at":"2025-03-21T17:51:08.000Z","dependencies_parsed_at":"2022-08-08T11:30:18.260Z","dependency_job_id":"f9857bfc-1ab5-421d-81e2-0d8df308731d","html_url":"https://github.com/yangshun/tree-node-cli","commit_stats":{"total_commits":76,"total_committers":8,"mean_commits":9.5,"dds":0.368421052631579,"last_synced_commit":"42797f074a37ecb8c7a3004884016c7a5b5288d9"},"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yangshun%2Ftree-node-cli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yangshun%2Ftree-node-cli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yangshun%2Ftree-node-cli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yangshun%2Ftree-node-cli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yangshun","download_url":"https://codeload.github.com/yangshun/tree-node-cli/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248647259,"owners_count":21139081,"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":["cli","directory","file","hacktoberfest","linux","node","tree"],"created_at":"2024-07-30T19:01:24.345Z","updated_at":"2025-04-12T23:33:41.940Z","avatar_url":"https://github.com/yangshun.png","language":"JavaScript","readme":"# tree-node-cli\n\nLists the contents of directories in a tree-like format, similar to the Linux [`tree`](https://linux.die.net/man/1/tree) command. Both CLI and Node APIs are provided.\n\n`tree` is a command that produces a nicely-formatted indented output of directories and files. When a directory argument is given, tree lists all the files and/or directories found in the given directory.\n\nNote: Symlinks are not followed.\n\n## Quickstart\n\nInstantly execute the command in your current directory via `npx`:\n\n```bash\nnpx tree-node-cli -I \"node_modules\" # ignore node_modules\n```\n\nOr via Yarn 2+:\n\n```bash\nyarn dlx -p tree-node-cli tree -I \"node_modules\" # ignore node_modules\n```\n\n## Installation\n\n```bash\n$ npm install tree-node-cli\n# or globally\n$ npm install -g tree-node-cli\n```\n\n## Example\n\n```bash\n$ tree -L 2 -I \"node_modules\"\ntree-node-cli\n├── LICENSE\n├── README.md\n├── __tests__\n│   ├── __fixtures__\n│   ├── __snapshots__\n│   ├── fixtures\n│   └── tree.test.js\n├── bin\n│   └── tree\n├── jest.config.js\n├── package.json\n├── tree.js\n└── yarn.lock\n```\n\n## CLI\n\n```bash\n$ tree [options] [path/to/dir]\n```\n\n**Note:** Use the command `treee` on Windows and Linux to avoid conflicts with built-in `tree` command.\n\nThe following options are available:\n\n```txt\n$ tree -h\n\n  Usage: tree [options]\n\n  Options:\n\n    -V, --version             output the version number\n    -a, --all-files           All files, include hidden files, are printed.\n    --dirs-first              List directories before files.\n    -d, --dirs-only           List directories only.\n    -s, --sizes               Show filesizes.\n    -I, --exclude [patterns]  Exclude files that match the pattern. | separates alternate patterns. Wrap your entire pattern in double quotes. E.g. `\"node_modules|coverage\".\n    -L, --max-depth \u003cn\u003e       Max display depth of the directory tree.\n    -r, --reverse             Sort the output in reverse alphabetic order.\n    -F, --trailing-slash      Append a '/' for directories.\n    -S, --line-ascii          Turn on ASCII line graphics.\n    -h, --help                output usage information\n```\n\n## Node.js API\n\n```js\nconst tree = require('tree-node-cli');\nconst string = tree('path/to/dir', options);\n```\n\n`options` is a configuration object with the following fields:\n\n| Field           | Default                    | Type    | Description                                                                                                                           |\n| --------------- | -------------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------- |\n| `allFiles`      | `false`                    | Boolean | All files are printed. By default, tree does not print hidden files (those beginning with a dot).                                     |\n| `dirsFirst`     | `false`                    | Boolean | List directories before files.                                                                                                        |\n| `dirsOnly`      | `false`                    | Boolean | List directories only.                                                                                                                |\n| `sizes`         | `false`                    | Boolean | Show filesizes as well.                                                                                                               |\n| `exclude`       | `[]`                       | Array   | An array of regex to test each filename against. Matching files will be excluded and matching directories will not be traversed into. |\n| `maxDepth`      | `Number.POSITIVE_INFINITY` | Number  | Max display depth of the directory tree.                                                                                              |\n| `reverse`       | `false`                    | Boolean | Sort the output in reverse alphabetic order.                                                                                          |\n| `trailingSlash` | `false`                    | Boolean | Appends a trailing slash behind directories.                                                                                          |\n| `lineAscii`     | `false`                    | Boolean | Turn on ASCII line graphics.                                                                                                          |\n\n```js\nconst string = tree('path/to/dir', {\n  allFiles: true,\n  exclude: [/node_modules/, /lcov/],\n  maxDepth: 4,\n});\n\nconsole.log(string);\n```\n\n_Note:_ To exclude the contents of a directory while retaining the directory itself, use a trailing slash with the `-I` option (e.g., `-I \"node_modules/\"`). For the Node.js API, provide a regex matching the directory contents (e.g., `/node_modules\\//`). See Issue https://github.com/yangshun/tree-node-cli/issues/33 for more details.\n\n## License\n\nMIT\n","funding_links":[],"categories":["JavaScript","Node"],"sub_categories":["工具库"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyangshun%2Ftree-node-cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyangshun%2Ftree-node-cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyangshun%2Ftree-node-cli/lists"}