0.0.2 • Published 9 years ago

no-promise-dir-tree v0.0.2

Weekly downloads
4
License
ISC
Repository
github
Last release
9 years ago

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
}