Package Exports
- directory-tree
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (directory-tree) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
#directory-tree
Creates an javascript object representing a directory tree.
Install
npm i -S directory-tree
##Usage
var dirTree = require('directory-tree');
var tree = dirTree('/some/path');And you can also filter by extensions:
var dirTree = require('directory-tree');
var filteredTree = dirTree('/some/path', ['.jpg', '.png']);This will take a directory tree:
photos
├── summer
│ └── june
│ └── windsurf.jpg
└── winter
└── january
├── ski.png
└── snowboard.jpgAnd return a js object:
{
"path": "photos",
"name": "photos",
"size": 600,
"children": [
{
"path": "photos/summer",
"name": "summer",
"size": 400,
"children": [
{
"path": "photos/summer/june",
"name": "june",
"size": 400,
"children": [
{
"path": "photos/summer/june/windsurf.jpg",
"name": "windsurf.jpg",
"size": 400,
"extension": ".jpg"
}
]
}
]
},
{
"path": "photos/winter",
"name": "winter",
"size": 200,
"children": [
{
"path": "photos/winter/january",
"name": "january",
"size": 200,
"children": [
{
"path": "photos/winter/january/ski.png",
"name": "ski.png",
"size": 100,
"extension": ".png"
},
{
"path": "photos/winter/january/snowboard.jpg",
"name": "snowboard.jpg",
"size": 100,
"extension": ".jpg"
}
]
}
]
}
]
}Note
Device, FIFO and socket files are ignored.
Files to which the user does not have permissions are included in the directory tree, however, directories to which the user does not have permissions, along with all of its contained files, are completely ignored.
Dev
To run tests go the package root in your CLI and run,
$ npm testMake sure you have the dev dependcies installed (e.g. npm install .)
Node version
Check out version 0.1.1 if you need support for older versions of node.