A flexible CLI tool to display directory structures in a tree format, built with TypeScript and TDD.
- 🌳 Recursive Tree View: Visualizes your folder structure.
- 🙈 Gitignore Support: Automatically respects
.gitignorerules (hides ignored files, marks ignored folders). - 📏 Max Leaf Control: Skips displaying folder contents if the file count exceeds a threshold (
--maxLeaf). - 🔗 Symlink Handling: Safely skips symbolic links to prevent infinite loops.
- 📊 Summary Statistics: Optional summary of folders, files, and skipped items.
-
Install dependencies:
npm install
-
Build the project:
npm run build
Run the tool using node:
node dist/index.js [target-directory] [options]Options:
--summary,-s: Show a summary at the end (Total files, folders, skipped items).--maxLeaf=N,-m N: Collapse folders containing more thanNfiles.
Show current directory with summary:
node dist/index.js . -sShow a specific folder, limiting large directories:
node dist/index.js ./src -m 5Follow these steps to verify all features manually.
Create a playground directory with various edge cases:
# Create directories
mkdir -p verify_test/src verify_test/large verify_test/ignored_folder
# Create files
echo "console.log('hello')" > verify_test/src/index.ts
echo "export const x = 1" > verify_test/src/utils.ts
echo "secret" > verify_test/ignored_folder/secret.txt
echo "ignored_folder" > verify_test/.gitignore
# Create a "large" folder (5 files)
for i in {1..5}; do echo "content" > verify_test/large/file$i.txt; done
# Create a symbolic link
ln -s ../verify_test/src verify_test/src_linkTest A: Standard Tree & Gitignore Run:
node dist/index.js verify_test --summaryExpectation:
ignored_foldershould be marked as🚫 (ignored).src_linkshould NOT be visible (symlinks skipped).- Summary should be displayed.
Test B: Max Leaf Threshold Run:
node dist/index.js verify_test --maxLeaf=3 --summaryExpectation:
largefolder should be marked📚 (too many files)because it has 5 files (> 3).- Its contents (
file1.txt...) should NOT be listed.
rm -rf verify_testThe project includes a comprehensive test suite using Jest.
npm test