parse-dir

4.0.2 • Public • Published

parse-dir Build Status

=========

Greenkeeper badge

Node lib to recursively read the files in a directory and return their contents.

Installation

npm install parse-dir

Usage

parseDir(glob, callback);

Or, if you prefer to make it synchronous:

var result = parseDir(glob);
var otherResult = parseDir.sync(otherGlob);

Example

var parseDir = require('parse-dir');

parseDir('*', function(err, files) {

});

Output

[
  {
    fullpath: '/path/to/file.ext',
    filename: 'file.ext',
    basename: 'file',
    extension: '.ext',
    raw: 'raw contents of file',
    contents: 'parsed contents of file',
    parsed: true|false //if file is supported, it will parse the contents.  If false, contents == raw.  See Parsing Files.
  }
]

Parsing Files

If parseDir knows how to parse a file, it will attempt to read it and turn it into a javascript object.

Supported Files

  • YAML
  • JSON
  • JS
  • CoffeeScript
  • Livescript

Readme

Keywords

none

Package Sidebar

Install

npm i parse-dir

Weekly Downloads

35

Version

4.0.2

License

MIT

Unpacked Size

23.8 kB

Total Files

37

Last publish

Collaborators

  • jga
  • dawnerd
  • ecwillis
  • orthagonal1
  • alaguna
  • aleperez92