You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Cache lstatSync results to avoid redundant syscalls and move exclude note in README
Stat each directory entry once and reuse cached results across sorting,
filtering, and tree building. Move the -I trailing slash documentation
to after the CLI options section and add it to the options table.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
**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 [#33](https://github.com/yangshun/tree-node-cli/issues/33) for more details.
93
+
92
94
## Node.js API
93
95
94
96
### `tree(path, options?)`
@@ -114,10 +116,15 @@ Returns the tree as a structured `TreeJsonEntry` object (or `null` if the path i
114
116
```ts
115
117
// Discriminated union — `contents` only exists on directories
|`dirsFirst`|`false`|`boolean`| List directories before files. |
143
150
|`fullPath`|`false`|`boolean`| Print the full path prefix for each file. |
144
151
|`noIndent`|`false`|`boolean`| Print entries without tree indentation lines. |
145
-
|`permissions`|`false`|`boolean`| Show file type and permissions (e.g. `[drwxr-xr-x]`). |
152
+
|`permissions`|`false`|`boolean`| Show file type and permissions (e.g. `[drwxr-xr-x]`). |
146
153
|`quote`|`false`|`boolean`| Quote filenames in double quotes. |
147
154
|`prune`|`false`|`boolean`| Remove empty directories from output. |
148
155
|`dirsOnly`|`false`|`boolean`| List directories only. |
149
156
|`sizes`|`false`|`boolean`| Show filesizes as well. |
150
-
|`exclude`|`[]`|`RegExp[]`| An array of regex to test each filename against. Matching files will be excluded and matching directories will not be traversed into. |
157
+
|`exclude`|`[]`|`RegExp[]`| An array of regex to test each filename against. Matching files will be excluded and matching directories will not be traversed into. To exclude a directory's contents while still showing the directory itself, use a regex that matches the path with a trailing slash (e.g., `/node_modules\//`). |
151
158
|`maxDepth`|`Number.POSITIVE_INFINITY`|`number`| Max display depth of the directory tree. |
152
159
|`reverse`|`false`|`boolean`| Sort the output in reverse alphabetic order. |
153
160
|`trailingSlash`|`false`|`boolean`| Appends a trailing slash behind directories. |
154
161
|`lineAscii`|`false`|`boolean`| Turn on ASCII line graphics. |
155
162
|`filesFirst`|`false`|`boolean`| List files before directories. |
|`unsorted`|`false`|`boolean`| Do not sort. List files in directory order. |
158
-
159
-
**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 [#33](https://github.com/yangshun/tree-node-cli/issues/33) for more details.
0 commit comments