Learn about our RFC process, Open RFC meetings & more.Join in the discussion! »

treek

1.0.3 • Public • Published

treek Build Status Download Version

Convert the specified directory tree to a JS object

Install

yarn add treek

Usage

const treek = require('treek')
console.log(treek('/your/directory'))

Option

Use regular expressions to ignore some folders or file names

treek('/your/directory', {
  ignore: /node_modules/
})

Use ext to get only the file containing the extension

treek('/your/directory', {
  ext: ['.js', '.ts']
})

Result

[
  {
    name: 'package.json',
    path: '/User/root/Desktop/treek/package.json',
    type: 'file',
    size: 305,
    extension: '.json',
    children: []
  }, {
    name: 'src',
    path: '/User/root/Desktop/treek/src',
    type: 'directory',
    size: 888,
    extension: null,
    children: [
      {
        name: 'index.js',
        path: '/User/root/Desktop/treek/src/index.js',
        type: 'file',
        size: 342,
        extension: '.js',
        children: []
      }
      // ...
    ]
  }
]

Install

npm i treek

DownloadsWeekly Downloads

1

Version

1.0.3

License

MIT

Unpacked Size

3.84 kB

Total Files

6

Last publish

Collaborators

  • avatar