directory-structur

1.0.1 • Public • Published

directory-structur

Get directory structur

Install

$ npm install -g directory-structur

Usage CLI

On terminal, type

  • $ dir-tree or
  • $ directory-structur

Options

Property Type Description
ignore Array or string Ignore it when find
maxDept number Limit max dept on directory
print `json tree`
path string Only support on cli

More CLI Example

  • $ dir-tree maxDept=10
  • $ dir-tree ignore=[\"node-modules\",\"json\"]
  • $ dir-tree print=json
  • $ dir-tree path=../

Javascript API

$ npm install directory-structur or $ yarn add directory-structur

const dir = require('directory-structur'); // or
// import dir from 'directory-structur';

const options = {
  ignore: ['node-modules'],
  //... other options
};
const res = dir('./', options);
console.log(res);

Output example tree

My Directory
├--.editorconfig
├--.gitignore
├--.npmignore
├--.prettierrc.js
├--.vscode
|  ├--extensions.json
|  ├--settings.json
├--README.md
├--cli.js
├--func.js
├--index.js
├--node_modules
|  ├--.yarn-integrity
|  ├--node-argv-to-object
|  |  ├--README.md
|  |  ├--index.js
|  |  ├--package.json
|  |  ├--sample.js
├--package.json
├--yarn.lock

Output example json

{
	path: './',
	name: 'My Directory',
	depth: 0,
	parent: 1,
	type: 'directory',
	children: [{
			path: '.editorconfig',
			name: '.editorconfig',
			depth: 0,
			parent: 0,
			type: 'file',
			extension: '.editorconfig'
		},
		{
			path: '.gitignore',
			name: '.gitignore',
			depth: 0,
			parent: 0,
			type: 'file',
			extension: '.gitignore'
		},
		{
			path: '.npmignore',
			name: '.npmignore',
			depth: 0,
			parent: 0,
			type: 'file',
			extension: '.npmignore'
		},
		{
			path: '.prettierrc.js',
			name: '.prettierrc.js',
			depth: 0,
			parent: 0,
			type: 'file',
			extension: '.js'
		},
		{
			path: '.vscode',
			name: '.vscode',
			depth: 0,
			parent: 0,
			type: 'directory',
			children: [Array]
		},
		{
			path: 'README.md',
			name: 'README.md',
			depth: 0,
			parent: 0,
			type: 'file',
			extension: '.md'
		},
		{
			path: 'cli.js',
			name: 'cli.js',
			depth: 0,
			parent: 0,
			type: 'file',
			extension: '.js'
		},
		{
			path: 'func.js',
			name: 'func.js',
			depth: 0,
			parent: 0,
			type: 'file',
			extension: '.js'
		},
		{
			path: 'index.js',
			name: 'index.js',
			depth: 0,
			parent: 0,
			type: 'file',
			extension: '.js'
		},
		{
			path: 'node_modules',
			name: 'node_modules',
			depth: 0,
			parent: 0,
			type: 'directory',
			children: [Array]
		},
		{
			path: 'package.json',
			name: 'package.json',
			depth: 0,
			parent: 0,
			type: 'file',
			extension: '.json'
		},
		{
			path: 'yarn.lock',
			name: 'yarn.lock',
			depth: 0,
			parent: 0,
			type: 'file',
			extension: '.lock'
		}
	]
}

Package Sidebar

Install

npm i directory-structur

Weekly Downloads

1

Version

1.0.1

License

MIT

Unpacked Size

6.81 kB

Total Files

5

Last publish

Collaborators

  • indaam