Generate an ascii tree structure for a file glob pattern.
E.g for this repo:
.
├─ .editorconfig
├─ .gitignore
├─ .travis.yml
├─ CHANGELOG.md
├─ LICENSE
├─ README.md
├─ index.js
├─ package.json
├─ yarn.lock
└─ __tests__
├─ index.test.js
├─ __fixtures__
│ └─ globs.json
└─ __snapshots__
└─ index.test.js.snap
The simplest way to use ascii-file-tree
is to just run it with npx. It will output a tree representing your current working directory.
npx ascii-file-tree
Alternatively install it globally, so npx doesn't have to download it everytime.
yarn global add ascii-file-tree
# or
npm install ascii-file-tree --global
# then run it with just
ascii-file-tree
There are a few options you can pass to the CLI.
Usage: ascii-file-tree [options] [globs...]
Generate an ascii tree structure for a file glob pattern.
Options:
-v, --version output the version number
-p, --path display root path instead of "."
-c, --cwd <path> the current working directory to search (default: process.cwd())
-d, --deep <n> only traverse n levels deep
-i, --ignore <globs> exclude matches with an array of glob patterns
-D, --no-dot exclude matches with directory or file names that start with a dot
-F, --no-follow exclude symlinks
-C, --no-case disable case-insensitive matching
-h, --help output usage information
Install ascii-file-tree
locally and save it as a dependency.
yarn add ascii-file-tree
# or
npm install ascii-file-tree --save
Import it into your project, and call the generate function.
const aft = require('ascii-file-tree');
// or
import aft from 'ascii-file-tree');
// Will log the file structure of your CWD excluding node_modules and .git.
console.log(aft.generate());
Returns the generated file structure string.
Name | Descriptions | Default |
---|---|---|
path (boolean) | Whether to display the root path instead of "." | false |
glob (string[]) | An array of globs. | ['./source/**/*.js', '!*.test.js'] |
globOptions (Object) | Options passed to fast-glob | { dot: true } |