项目作者: joscha

项目描述 :
Generate an index from a directory
高级语言: JavaScript
项目地址: git://github.com/joscha/indexifier.git
创建时间: 2016-09-29T14:25:58Z
项目社区:https://github.com/joscha/indexifier

开源协议:MIT License

下载


Generate an index for a given directory

Greenkeeper badge

Build status
npm
npm
node
Commitizen friendly
semantic-release

This module generates a tree view of a given directory.

Usage

CLI API

  1. Usage: indexifier [options] <dir>
  2. Options:
  3. -h, --help output usage information
  4. -V, --version output the version number
  5. -e, --extensions <list> The extensions to take into account (defaults to .htm,.html)
  6. -I, --include <regexp> Include files and directories that are matched by this regular expression (defaults to all)
  7. -E, --exclude <regexp> Exclude files and directories that are matched by this regular expression (defaults to none)
  8. -H, --html Enable to generate HTML output
  9. -L, --no-link-folders Do not link folders when in HTML output mode
  10. -F, --no-empty-directories Do not include empty directories
  11. -D, --max-depth Limit results to a maximum sub-directory depth

Install

  1. npm install -g indexifier

Examples

  1. indexifier ./ --extensions .html,.htm

would generate something like this:

  1. A
  2. ├─┬ B
  3. └── c.html
  4. ├── d.html
  5. └── e.html

There is also an HTML flag that would generate the above output as linked HTML:

  1. indexifier --extensions .html --html .
  1. <!-- ... -->
  2. <a href="./">A</a><br/>
  3. ├─┬ <a href="./B">B</a><br/>
  4. │ └── <a href="./B/c.html">c.html</a><br/>
  5. ├── <a href="./d.html">a.html</a><br/>
  6. └── <a href="./e.html">b.html</a><br/>
  7. <!-- ... -->

The links are always relative to the given directory.

Node API

  1. indexifier(String directory [, opts={
  2. fileTypes: Array.<String>,
  3. include=undefined: Regexp,
  4. exclude=undefined: Regexp,
  5. isHtml=false: Boolean,
  6. linkFolders=true: Boolean,
  7. emptyFolders=true: Boolean,
  8. maxDepth=Infinity: Number,
  9. }]);

Install

  1. npm install indexifier --save

Examples

Tree of files:

  1. const indexifier = require('indexifier');
  2. const treeOfFiles = indexifier(__dirname);

Tree of HTML files:

  1. const indexifier = require('indexifier');
  2. const treeOfHtmlFiles = indexifier(__dirname, { fileTypes: ['.html'] });

or for HTML output:

  1. const indexifier = require('indexifier');
  2. const treeOfJpegFiles = indexifier(__dirname, {
  3. fileTypes: ['.jpg', '.jpeg'],
  4. isHtml: true
  5. });