npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

filetree.js

v0.0.3

Published

Recursively list files in directory hierarchy as a readable tree upto specified depth while excluding unwanted folder names

Downloads

3

Readme

filetree.js

Recursively list files in directory hierarchy as a readable tree upto specified depth while excluding unwanted folder names

Install

Global

npm install -g filetree.js

Local

npm install --save filetree.js

CLI Example

Recursively lists files in myFolder and subdirectories upto two levels down, excluding any file or folder with the name node_modules and bower_components. Includes normally hidden files and folders and does not indent file/folder paths based on their depth level.

./filetree --path ./myFolder \
           --max-depth 2 \
           --exclude node_modules bower_components \
           --all \
           --no-indent

JavaScript Example

Same as the CLI Example.

var filetree = require('filetree.js');
filetree({
    path: './myFolder',
    maxDepth: 2,
    exclude: ['node_modules', 'bower_components'],
    all: true,
    indent: false
});

JavaScript API

All arguments are optional

filetree(options)

  • options.path
    • String
    • Default = Current working directory
    • Print contents of directory at this path (relative or absolute)
  • options.maxDepth
    • Integer
    • Default = Unlimited
    • Maximum directory recursion depth
  • options.exclude
    • Array:String
    • Default = []
    • Exclude file and folder names
  • options.all
    • Boolean
    • Default = false
    • Include files and folders beginning with a period
  • options.indent
    • Boolean
    • Default = true
    • Indent paths based on their depth level

CLI API

All arguments are optional

filetree [-p <target path>]
         [-m <max recursion depth>]
         [-x <excluded names>]
         [-a]
         [-i]

Options:
  --path, -p       Print contents of directory at this path (relative or
                   absolute)
                    [string] [default: /Users/aihamhammami/Projects/filetree.js]
  --max-depth, -m  Maximum directory recursion depth        [default: Unlimited]
  --exclude, -x    Exclude file and folder names           [array] [default: []]
  --all, -a        Include files and folders beginning with a period
                                                      [boolean] [default: false]
  --indent, -i     Indent paths based on their depth level
                                                       [boolean] [default: true]
  --version, -V    Show version number                                 [boolean]
  --help, -h       Show help                                           [boolean]

Examples:
  filetree -m 0                Only print root directory
  filetree -m 2                Print root and the two lower levels of
                               directories
  filetree -x build tmp test   Exclude multiple folder names
  filetree -p myGitProject -a  Includes .git which is normally ignored
  filetree --no-indent         Prevent the default indentation

Report bugs at https://github.com/aiham/filetree.js/issues

Tests

Run the tests. Uses: mocha, chai, sinon

npm test

To Do

  • Return paths in JS and print in CLI
  • Async with promises rather than synchronous

Change Log

  • 2015-10-18 - v0.0.3
    • Fix global command to be filetree rather than filetree.js
  • 2015-10-18 - v0.0.2
    • Allow exclude names to have hanging/trailing slash
  • 2015-10-18 - v0.0.1
    • First release