no-promise-dir-tree

0.0.2 • Public • Published

no-promise-dir-tree

Creates a JavaScript object representing the directory structure of a given path. Without Promises. Fork of uniqname/dir-tree.

API

dirTree = require('dir-tree', cb);

Given a directory structure of the following

/demo/
  dir1/
    file1.txt
   dir2/
   dir3/
    file2.js
    file3.js

Promises

dirTree returns a promise that resolves with the directory tree object.

dirTree('/demo', function (err, tree) {
  if (err) {
    console.log(err);
    return;
  }
  console.log(tree);
});

The output of the above would be...

{
  'dir1': {
    'file1.txt': true,
    'dir2': {}
  },
  'dir3': {
    'file2.js': true
  },
  'file3.js': true
}

Readme

Keywords

none

Package Sidebar

Install

npm i no-promise-dir-tree

Weekly Downloads

0

Version

0.0.2

License

ISC

Last publish

Collaborators

  • michalbe