Skip to content
This repository has been archived by the owner on Sep 7, 2019. It is now read-only.

Generate an ascii tree structure for a file glob pattern.

License

Notifications You must be signed in to change notification settings

AndrewLeedham/ascii-file-tree

Repository files navigation

Archived in favour of built in tree command, was not aware of it when I built this...

ascii-file-tree

Generate an ascii tree structure for a file glob pattern.

travisci status npm package license MIT commit style angular semantic-release Dependabot Status

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

Usage

CLI

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

JavaScript

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());

API

generate([options])

Returns the generated file structure string.

options

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 }

LICENSE | CHANGELOG | ISSUES

About

Generate an ascii tree structure for a file glob pattern.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •