Skip to content

Commit

Permalink
better examples
Browse files Browse the repository at this point in the history
  • Loading branch information
grrowl committed Jun 29, 2024
1 parent 40fbca9 commit 37883ea
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ The tool will output a tree-like structure of your project, including files, dir
│ │ └─ formatDate(date: Date): string
```

More comprehensive example output can be found in the [test snapshots for this very project](https://github.com/grrowl/ts-print-tree/blob/main/src/__snapshots__/index.test.ts.snap).

## 🔧 Customization

You can customize ignored patterns by passing them as arguments to the CLI command. For example:
Expand Down
11 changes: 10 additions & 1 deletion src/__snapshots__/index.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,16 @@ exports[`tree module calls tree() and matches console.log snapshot 1`] = `
exports[`tree module calls tree() with custom ignored patterns and matches console.log snapshot 1`] = `
[
[
"",
"└─ src/
└─ tests/
├─ class.ts
│ └─ export default class DefaultClass
│ └─ class NamedClass
└─ consts.ts
└─ const publicArray
└─ interface PublicInterface
└─ const publicFunction
",
],
]
`;
Expand Down
2 changes: 1 addition & 1 deletion src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe("tree module", () => {

test("calls tree() with custom ignored patterns and matches console.log snapshot", () => {
console.log = jest.fn();
const customIgnored = ["node_modules", /\.git/, /^src\/(?!tests\/)/];
const customIgnored = ["node_modules", /\.git/, /^src\/(?!tests)/];

tree(process.cwd(), customIgnored);
expect((console.log as jest.Mock).mock.calls).toMatchSnapshot();
Expand Down

0 comments on commit 37883ea

Please sign in to comment.