node-map-directory

0.1.0 • Public • Published

node-map-directory

Asyncronously map directory file structure into a JavaScript object

Install

NPM

Build Status

$ npm install node-map-directory

Usage

var mapDir = require('node-map-directory');
mapDir('./')
  .then(function(currentDirMap) {
    // some code
  });
 
/* You will get an array of file and directory objects
 
  Directory structure
  - currentDir
    - index.html
    - scripts
      - myScript.js
 
  Output:
  [
    {
      name: 'index',
      extension: '.html',
      type: 'file'
    },
    {
      name: 'scripts',
      type: 'dir',
      children: [
        {
          name: 'myScript',
          extension: '.js',
          type: 'file'
        }
      ]
    }
  ]
*/

API

mapDir(directory, toIgnore)

options

directory

Type: String
Default: ./

The root directory to get the map from.

toIgnore

Type: array
Default: ['node_modules', 'bower_components', '.ignored_file']

The directories and files to exclude from mapping.

License

MIT © Dorian Camilleri

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.1.0
    203
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.1.0
    203
  • 0.0.4
    3
  • 0.0.3
    2
  • 0.0.2
    2
  • 0.0.1
    2

Package Sidebar

Install

npm i node-map-directory

Weekly Downloads

179

Version

0.1.0

License

MIT

Last publish

Collaborators

  • dcamilleri