0.0.1 • Published 4 years ago

dir-tree-obj v0.0.1

Weekly downloads
85
License
MIT
Repository
github
Last release
4 years ago

dir-tree-obj

Build Status npm version Node.js Version

Create a JavaScript object representing the structure of a directory

Installation

yarn add dir-tree-obj

Usage

Assume a directory named dir with the following structure:

├── a.txt
├── b.txt
└── sub
    ├── a.js
    ├── a.txt
    └── b.txt
import dirTreeObj from 'dir-tree-obj';

dirTreeObj('./dir');
/**
 * Prints: {
    '.': ['a.txt', 'b.txt'],
    sub: {
      '.': ['a.js', 'a.txt', 'b.txt'],
    },
  }
 */

Note: file names are always sorted.