Skip to content

Commit 2f21623

Browse files
yangshunclaude
andcommitted
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>
1 parent 3c72306 commit 2f21623

1 file changed

Lines changed: 35 additions & 28 deletions

File tree

‎README.md‎

Lines changed: 35 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ npm install -g tree-node-cli
2525
## Example
2626

2727
```bash
28-
$ tree -L 2 -I "node_modules"
28+
$ tree -L 2
2929
tree-node-cli
3030
├── CNAME
3131
├── LICENSE
@@ -42,13 +42,17 @@ tree-node-cli
4242
└── tsdown.config.ts
4343
```
4444

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+
4548
## CLI
4649

4750
```bash
4851
tree [options] [path/to/dir]
4952
```
5053

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.
5256
5357
The following options are available:
5458

@@ -108,7 +112,10 @@ Misc options:
108112
--version Display version number
109113
```
110114

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.
112119
113120
## Node.js API
114121

@@ -121,7 +128,7 @@ import { tree } from 'tree-node-cli';
121128

122129
const string = tree('path/to/dir', {
123130
allFiles: true,
124-
exclude: [/node_modules/, /lcov/],
131+
exclude: [/vendor/, /lcov/],
125132
maxDepth: 4,
126133
});
127134

@@ -162,30 +169,30 @@ console.log(result);
162169

163170
`options` is a configuration object with the following fields:
164171

165-
| Field | Default | Type | Description |
166-
| --------------- | -------------------------- | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
167-
| `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. |
182-
| `sortBy` | `'name'` | `string` | Sort the output. Options: `'name'`, `'version'`, `'mtime'`, `'ctime'`, `'size'`. |
183-
| `unsorted` | `false` | `boolean` | Do not sort. List files in directory order. |
184-
| `reverse` | `false` | `boolean` | Sort the output in reverse alphabetic order. |
185-
| `dirsFirst` | `false` | `boolean` | List directories before files. |
186-
| `filesFirst` | `false` | `boolean` | List files before directories. |
187-
| `noIndent` | `false` | `boolean` | Print entries without tree indentation lines. |
188-
| `lineAscii` | `false` | `boolean` | Turn on ASCII line graphics. |
172+
| Field | Default | Type | Description |
173+
| --------------- | -------------------------- | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
174+
| `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. |
189+
| `sortBy` | `'name'` | `string` | Sort the output. Options: `'name'`, `'version'`, `'mtime'`, `'ctime'`, `'size'`. |
190+
| `unsorted` | `false` | `boolean` | Do not sort. List files in directory order. |
191+
| `reverse` | `false` | `boolean` | Sort the output in reverse alphabetic order. |
192+
| `dirsFirst` | `false` | `boolean` | List directories before files. |
193+
| `filesFirst` | `false` | `boolean` | List files before directories. |
194+
| `noIndent` | `false` | `boolean` | Print entries without tree indentation lines. |
195+
| `lineAscii` | `false` | `boolean` | Turn on ASCII line graphics. |
189196

190197
## License
191198

0 commit comments

Comments
 (0)