GithubHelp home page GithubHelp logo

codysmithd / pretty-file-tree Goto Github PK

View Code? Open in Web Editor NEW
7.0 2.0 2.0 591 KB

A tiny, simple utility for pretty-printing lists of file paths as a tree for command-line-interfaces.

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

JavaScript 100.00%

pretty-file-tree's Introduction

pretty-file-tree

Build Status

A tiny, simple utility for pretty-printing lists of file paths as a tree for command-line-interfaces.

Example

const prettyTree = require('pretty-file-tree');

console.log(prettyTree([
    'home/user/foo.js',
    'home/user/test/bar.js',
    'home/user/test/baz.js',
    'home/user/bat.js'
]));

Result

home/user
├── foo.js
├── test
|  ├── bar.js
|  └── baz.js
└── bat.js

Configuring the output tree style

It is possible to change the style of the tree.

Example

const prettyTree = require('pretty-file-tree');

const options = {
    throughTee: '├>',
    endTee: '└>' 
}

console.log(prettyTree([
    'home/user/foo.js',
    'home/user/test/bar.js',
    'home/user/test/baz.js',
    'home/user/bat.js'
], options));

Result

home/user
├> foo.js
├> test
|  ├> bar.js
|  └> baz.js
└> bat.js

Style Options

throughTee

  • throughTee option refers to the "├──" default string.

endTee

  • endTee option refers to the "└──" default string.

vertical

  • vertical option refers to the "| " default string.

emptyColumn

  • emptyColumn option refers to the " " default string.

pretty-file-tree's People

Contributors

codysmithd avatar pultzlucas avatar dependabot[bot] avatar

Stargazers

Katzper Michno avatar Dillon Mulroy avatar Denis Tokarev avatar  avatar Greg Zaal avatar  avatar Tristin avatar

Watchers

James Cloos avatar  avatar

Forkers

pultzlucas

pretty-file-tree's Issues

Param for specifying tabulation?

Hi @codysmithd!

Thanks for a great lib – it's very useful 👏
I'm wondering if you could add an option to customize the number of spaces between | at different file system levels?
By default, it's 2 spaces (space = 2x" "), like this:

├── dir
|  ├── file_1.txt
|  ├── subdir
|  |  ├── file_1.txt
|  |  ├── file_2.txt
|  |  └── file_3.txt
|  └── file_2.txt
└── file.txt

But I'm wondering if you could add an option to do this? (space = 3x" ")

├── dir
|   ├── file_1.txt
|   ├── subdir
|   |   ├── file_1.txt
|   |   ├── file_2.txt
|   |   └── file_3.txt
|   └── file_2.txt
└── file.txt

Or this? (space = 4x" ")

├── dir
|    ├── file_1.txt
|    ├── subdir
|    |    ├── file_1.txt
|    |    ├── file_2.txt
|    |    └── file_3.txt
|    └── file_2.txt
└── file.txt

Or any other arbitrary number of spaces?

Publish the change with options

The style options change in August of 2021 are not in NPM vs 1.0.1. Would it possible to make another release with the latest repo?

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.