ascii-file-tree

Generate an ascii tree structure for a file glob pattern.

Deprecating in favour of built in tree command, was not aware of it when I built this...
Last updated a year ago by andrewleedham .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install ascii-file-tree 
SYNC missed versions from official npm registry.

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

Current Tags

  • 1.2.2                                ...           latest (a year ago)

6 Versions

  • 1.2.2 [deprecated]           ...           a year ago
  • 1.2.1 [deprecated]           ...           a year ago
  • 1.2.0 [deprecated]           ...           a year ago
  • 1.1.0 [deprecated]           ...           a year ago
  • 1.0.1 [deprecated]           ...           a year ago
  • 1.0.0 [deprecated]           ...           a year ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 6
Dependencies (3)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |