1.0.1 • Published 4 years ago

directory-structur v1.0.1

Weekly downloads
1
License
MIT
Repository
-
Last release
4 years ago

directory-structur

Get directory structur

Install

$ npm install -g directory-structur

Usage CLI

On terminal, type

  • $ dir-tree or
  • $ directory-structur

Options

PropertyTypeDescription
ignoreArray or stringIgnore it when find
maxDeptnumberLimit max dept on directory
printjson | treeSelect output type
pathstringOnly 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'
		}
	]
}