Skip to content
/ dir-prop Public

Read directory into JSON tree module for node.

Notifications You must be signed in to change notification settings

pqab/dir-prop

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Read directory into JSON tree module for node.

NPM version

Installation

npm install dir-prop

Usage

const { dirProp } = require('dir-prop');
dirProp({
  root: path.join(__dirname, '../')
}).then((data) => {
  console.log(data);
});

Use with express server (Demo)

const { dirServer } = require('dir-prop');

app.use(express.static(path.join(__dirname, '../'),
  { dotfiles: 'allow' }));

app.use('/', dirServer({
  root: path.join(__dirname, '../'),
  template: true
}));

Options

options description default accept
exclude excluded directory name node_modules, .git [array]
recursion recursion from root directory true boolean
root specific relative or absolute directory __dirname String

Use with express server

options description default accept
app express app app
method http method for request param, otherwise will use default options param get, post
template use template if provided, otherwise will retuen raw json data String

dir to prop

root
  |- demo
      |- demo
  |- src
      |- index.js
      ...
  |- README.md
  ...

to

{
  demo: {
    demo: Stats { /* fs.stat */
      dev: 16777220,
      mode: 33188,
      nlink: 1,
      ...
    }
  },
  src : {
    'index.js': Stats {
      ...
    },
    ...
  },
  'README.md': Stats {
    ...
  }
}

About

Read directory into JSON tree module for node.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published