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
{{ message }}
Repository navigation
Commit 2f21623
Browse filesBrowse the repository at this point in the historyBrowse files
Update README: use admonitions, update examples for gitignore defaults
- Use GitHub admonitions ([!NOTE], [!IMPORTANT], [!TIP]) instead of bold notes
- Update examples to reflect gitignore-by-default (remove redundant -I "node_modules")
- Replace node_modules with vendor in exclude examples
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: README.md
+35-28Lines changed: 35 additions & 28 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,7 +25,7 @@ npm install -g tree-node-cli
25
25
## Example
26
26
27
27
```bash
28
-
$ tree -L 2 -I "node_modules"
28
+
$ tree -L 2
29
29
tree-node-cli
30
30
├── CNAME
31
31
├── LICENSE
@@ -42,13 +42,17 @@ tree-node-cli
42
42
└── tsdown.config.ts
43
43
```
44
44
45
+
> [!NOTE]
46
+
> `gitignore` is respected by default so `node_modules` and other common files/directories are excluded automatically. Use `--no-gitignore` to show them.
47
+
45
48
## CLI
46
49
47
50
```bash
48
51
tree [options] [path/to/dir]
49
52
```
50
53
51
-
**Note:** Use the command `treee` on Windows and Linux to avoid conflicts with built-in `tree` command.
54
+
> [!IMPORTANT]
55
+
> Use the command `treee` on Windows and Linux to avoid conflicts with built-in `tree` command.
52
56
53
57
The following options are available:
54
58
@@ -108,7 +112,10 @@ Misc options:
108
112
--version Display version number
109
113
```
110
114
111
-
**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.
115
+
> [!TIP]
116
+
> To exclude the contents of a directory while still printing the directory itself, use a trailing slash with the `-I` option (e.g., `-I "directory/"`).
117
+
>
118
+
> For the Node.js API, provide a regex matching the directory contents (e.g., `/directory\//`). Directories listed in `.gitignore` (e.g. `node_modules`) are already excluded by default, use `--no-gitignore` in combination with `-I "directory/"` if you want them to show up.
112
119
113
120
## Node.js API
114
121
@@ -121,7 +128,7 @@ import { tree } from 'tree-node-cli';
121
128
122
129
conststring=tree('path/to/dir', {
123
130
allFiles:true,
124
-
exclude: [/node_modules/,/lcov/],
131
+
exclude: [/vendor/,/lcov/],
125
132
maxDepth:4,
126
133
});
127
134
@@ -162,30 +169,30 @@ console.log(result);
162
169
163
170
`options` is a configuration object with the following fields:
|`allFiles`|`false`|`boolean`| All files, including hidden files, are printed. |
168
-
|`dirsOnly`|`false`|`boolean`| List directories only. |
169
-
|`fullPath`|`false`|`boolean`| Print the full path prefix for each file. |
170
-
|`maxDepth`|`Number.POSITIVE_INFINITY`|`number`| Max display depth of the directory tree. |
171
-
|`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\//`). |
172
-
|`gitignore`|`true`|`boolean`| Respect `.gitignore` files when inside a git repository. Use `--no-gitignore` to disable. |
173
-
|`prune`|`false`|`boolean`| Remove empty directories from output. |
174
-
|`quote`|`false`|`boolean`| Quote filenames in double quotes. |
175
-
|`permissions`|`false`|`boolean`| Show file type and permissions (e.g. `[drwxr-xr-x]`). |
176
-
|`sizes`|`false`|`boolean`| Print the size of each file in bytes along with the name. |
177
-
|`humanReadable`|`false`|`boolean`| Print file sizes in human-readable format (powers of 1024). Implies `sizes`. |
178
-
|`si`|`false`|`boolean`| Print file sizes using SI units (powers of 1000). Implies `sizes`. |
179
-
|`du`|`false`|`boolean`| For each directory, report its size as the accumulation of sizes of all its files and sub-directories. Implies `sizes`. |
180
-
|`date`|`false`|`boolean`| Show last modification time for each entry. |
181
-
|`trailingSlash`|`false`|`boolean`| Append a `/` for directories. |
|`allFiles`|`false`|`boolean`| All files, including hidden files, are printed. |
175
+
|`dirsOnly`|`false`|`boolean`| List directories only. |
176
+
|`fullPath`|`false`|`boolean`| Print the full path prefix for each file. |
177
+
|`maxDepth`|`Number.POSITIVE_INFINITY`|`number`| Max display depth of the directory tree. |
178
+
|`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., `/vendor\//`). |
179
+
|`gitignore`|`true`|`boolean`| Respect `.gitignore` files when inside a git repository. Use `--no-gitignore` to disable. |
180
+
|`prune`|`false`|`boolean`| Remove empty directories from output. |
181
+
|`quote`|`false`|`boolean`| Quote filenames in double quotes. |
182
+
|`permissions`|`false`|`boolean`| Show file type and permissions (e.g. `[drwxr-xr-x]`). |
183
+
|`sizes`|`false`|`boolean`| Print the size of each file in bytes along with the name. |
184
+
|`humanReadable`|`false`|`boolean`| Print file sizes in human-readable format (powers of 1024). Implies `sizes`. |
185
+
|`si`|`false`|`boolean`| Print file sizes using SI units (powers of 1000). Implies `sizes`. |
186
+
|`du`|`false`|`boolean`| For each directory, report its size as the accumulation of sizes of all its files and sub-directories. Implies `sizes`. |
187
+
|`date`|`false`|`boolean`| Show last modification time for each entry. |
188
+
|`trailingSlash`|`false`|`boolean`| Append a `/` for directories. |
0 commit comments