1.2.2 • Published 5 years ago

ascii-file-tree v1.2.2

Weekly downloads
11
License
MIT
Repository
github
Last release
5 years ago

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

NameDescriptionsDefault
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

1.2.2

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.0

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago