Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/firstandthird/parse-dir
Node lib to recursively read the files in a directory and return their contents
https://github.com/firstandthird/parse-dir
Last synced: 14 days ago
JSON representation
Node lib to recursively read the files in a directory and return their contents
- Host: GitHub
- URL: https://github.com/firstandthird/parse-dir
- Owner: firstandthird
- License: mit
- Created: 2014-05-22T15:32:24.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2022-04-14T03:04:46.000Z (almost 3 years ago)
- Last Synced: 2025-01-15T08:20:44.638Z (18 days ago)
- Language: JavaScript
- Size: 136 KB
- Stars: 1
- Watchers: 5
- Forks: 2
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
parse-dir
[![Build Status](https://travis-ci.org/firstandthird/parse-dir.svg?branch=master)](https://travis-ci.org/firstandthird/parse-dir)=========
[![Greenkeeper badge](https://badges.greenkeeper.io/firstandthird/parse-dir.svg)](https://greenkeeper.io/)
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:
```javascript
var result = parseDir(glob);
var otherResult = parseDir.sync(otherGlob);
```### Example
```javascript
var parseDir = require('parse-dir');parseDir('*', function(err, files) {
});
```### Output
```javascript
[
{
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