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

@linkcs/directory-tree

0.1.0 • Public • Published

TL;DR

Create a list of a given path:

folder/
   ┣━━ foo/
   ┃    ┗━━ bar/
   ┃         ┗━━ javascript.js
   ┃         ┗━━ python.py
   ┃         ┗━━ database.sql
   ┃
   ┣━━ paz/
   ┃
   ┗━━ ska/
        ┗━━ ignore.txt
const getTree = require("@linkcs/directory-tree");
 
getTree("./folder");
// {
//   foo: {
//     bar: {
//       "javascript.js": null,
//       "python.py": null,
//       "database.sql": null
//     }
//   },
//   ska: {
//     "ignore.txt": null
//   }
// }
 
getTree("./folder", { extensions: ".py" });
// {
//   foo: {
//     bar: {
//       "javascript.js": null,
//       "python.py": null,
//       "database.sql": null
//     }
//   },
//   ska: {
//     "ignore.txt": null
//   }
// }
 
getTree("./folder", { includeFiles: false });
// {
//   foo: {
//     bar: { }
//   },
//   ska: { }
// }

Options

option description default value
extensions Only include files of these extensions '.*'
ignoreExtensions Exclude files of these extensions null
ignoreFiles Regex to ignore certain files '\..*'
ignoreFolders Regex to ignore certain folders 'node_modules'
includeFiles Should list files in the tree true

};

Keywords

none

Install

npm i @linkcs/directory-tree

DownloadsWeekly Downloads

3

Version

0.1.0

License

MIT

Unpacked Size

5.1 kB

Total Files

19

Last publish

Collaborators

  • avatar
  • avatar
  • avatar