json-dir-listing

0.2.1 • Public • Published

json-dir-listing

Build Status Coverage Status

Tool for creating a file that contains the contents and types of everything in the directory.

Options

  • -d, --dryrun - Run through the process without actually creating any new files
  • -R, --recursive - Recursively create listings for all subfolders
  • -o, --output [name] - Specify the name to use for the file output (default .listings.json)
  • -s, --sparse [depth] - Create listings that only contains n [depth] of children (default null)
  • -b, --basepath [root] - Root for generated relative path (default '.')

Example

  1. mkdir tmp
  2. touch tmp/test.txt
  3. json-dir-listing tmp/
  4. Creates tmp/.listings.json containing
{
  "path":"tmp",
  "name":"tmp",
  "type":"folder",
  "children":[{
    "path":"tmp/test.txt",
    "name":"test.txt",
    "type":"file"
  }]
}

Why?

I wanted to create a dynamic client-only website as my personal CV/blog/whatever, but I didn't want it become bloated with the content itself so I decided to dynamically load and render all the content. The setup I was using doesn't allow directory listings, but allows file access so I created this to get a list of all files in a directory.

Package Sidebar

Install

npm i json-dir-listing

Weekly Downloads

7

Version

0.2.1

License

MIT

Last publish

Collaborators

  • caleb.morris