GithubHelp home page GithubHelp logo

andrewleedham / ascii-file-tree Goto Github PK

View Code? Open in Web Editor NEW
3.0 2.0 0.0 969 KB

Generate an ascii tree structure for a file glob pattern.

Home Page: https://www.npmjs.com/package/ascii-file-tree

License: MIT License

JavaScript 100.00%
ascii directory-tree file-tree

ascii-file-tree's Introduction

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

ascii-file-tree's People

Contributors

andrewleedham avatar dependabot-preview[bot] avatar greenkeeper[bot] avatar semantic-release-bot avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

ascii-file-tree's Issues

An in-range update of fast-glob is breaking the build 🚨

The dependency fast-glob was updated from 2.2.6 to 2.2.7.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

fast-glob is a direct dependency of this project, and it is very likely causing it to break. If other packages depend on yours, this update is probably also breaking those in turn.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build failed (Details).

Release Notes for 2.2.7

Another release of bug fixes

📖 Documentation

  • Added description of how to work with UNC paths (#89)
  • The ignore option takes an array (#184 — thanks @lukeis for contributing)
  • Clarify description of the case option.

🐛 Bug Fixes

Paths not resolved in some cases (#157)

Thanks @stevenvachon for issue reporting 🎉

If the user has passed a . or .. and the absolute option is enabled,
the paths of the found entries were not absolute (they contained . or `..).

before

fg.sync('/project/temp/../*.js', { absolute: true }); // → ['/project/temp/../something.js']

after

fg.sync('/project/temp/../*.js', { absolute: true }); // → ['/project/something.js']

The case option not work with static patterns (#172)

Thanks @davidmerfield for issue reporting 🎉

For performance reasons with [email protected] we introduce static patterns (patterns without glob magic).

Unfortunately, then we forgot about supporting the case (nocase) option. Now the case option works fine with static patterns too. We also improved the documentation for this option.

directory/
  - file.txt
  - File.txt

before

fg.sync('file.txt', { case: false }) // → ['file.txt']

after

fg.sync('file.txt', { case: false }) // → ['file.txt', 'File.txt']

Question mark is not recognized as dynamic glob and fails to find files (#174)

Thanks @vladshcherbin for issue reporting and contributing 🎉

This is also related to static patterns.

Previously we mark patterns like assets/?ss.css to static and tried to find such file on file system. Now it will works fine.

before

fg.sync('assets/?ss.css'); // → []

after

fg.sync('assets/?ss.css'); // → ['asserts/css.css']
Commits

The new version differs by 21 commits.

  • 85e42c3 build(package): bump version to 2.2.7
  • a0af28e docs(readme): how to use UNC path
  • 3ea4d8e fix(tasks): always mark patterns as dynamic with case-insensitive mode
  • b22e7be fix(providers): resolve path even for absolute filepath
  • 319b64d Add test for question mark glob
  • 7f259e6 Set is-glob strict to false
  • 62c0fbf Merge pull request #164 from mrmlnc/ISSUE-151_improve_documentation_about_entry_type
  • e7315d7 Merge pull request #165 from mrmlnc/TRIVIAL_update_deps
  • 52cec04 docs(README): clarify return type (fix #151)
  • 8b725de build: drop CI for Node.js 4
  • c41fe33 build: fix build issue after update dependencies
  • 5000834 build: update @types/node
  • 2ed70e8 style(index): use T[] instead of Array<T>
  • 5376d66 Merge pull request #150 from mrmlnc/update_tslint_config
  • a0bb8dd build: update "tslint-config-mrmlnc" to 2.0.0

There are 21 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.