dstruc
Get directories and files recursively.
Last updated 6 years ago by shockwork .
BSD-2-Clause · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install dstruc 
SYNC missed versions from official npm registry.

dstruc

Build Status

Quickly get directory structure and files from a specified path in node, with support for recursive operations.

Installation

$ npm install dstruc --save

Usage

var dstruc = require('dstruc');
var structure = dstruc.sync('/path/to/dir');
console.log(structure); 
/* 
{ files: [ 'level.one.file.txt' ],
  dirs:
   { another_level_two: { files: [Object], dirs: {} },
     level_two: { files: [Object], dirs: {} } } }
*/

var structureWithExtensions = dstruc.sync('/another/path/to/dir', { extensionAsKey: true });
console.log(structureWithExtensions);
/*{ files: { txt: [ 'one.file.txt', 'two.file.txt' ] }, dirs: {} }*/

Options

recursive: Will traverse directories until it reaches the bottom. If set to false, directories of the top level will instead be put in an array.

extensionAsKey: Will put the files in an object with their extension as the key instead of an array.

Testing

$ npm test

Todo

  • Add async version

License

BSD

Current Tags

  • 0.1.2                                ...           latest (6 years ago)

7 Versions

  • 0.1.2                                ...           6 years ago
  • 0.1.1                                ...           6 years ago
  • 0.1.0                                ...           6 years ago
  • 0.0.5                                ...           6 years ago
  • 0.0.4                                ...           6 years ago
  • 0.0.2                                ...           6 years ago
  • 0.0.1                                ...           6 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 2
Last Day 0
Last Week 0
Last Month 5
Dependencies (1)
Dev Dependencies (2)

Copyright 2014 - 2016 © taobao.org |