https://github.com/boycce/directory-json
✨ Converts a directory structure into JSON
https://github.com/boycce/directory-json
Last synced: 8 months ago
JSON representation
✨ Converts a directory structure into JSON
- Host: GitHub
- URL: https://github.com/boycce/directory-json
- Owner: boycce
- License: other
- Created: 2018-05-03T21:27:28.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-05-05T08:18:11.000Z (about 8 years ago)
- Last Synced: 2025-03-20T16:48:46.636Z (about 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 10.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Directory JSON
Converts a directory structure into JSON
## Installation
```shell
npm install directory-json --save
```
## Project Usage
```javascript
var directoryJson = require('directory-json')
directoryJson('./path/to/my/dir', function (err, res) {
if (err) return console.error(err)
console.log(res);
});
```
## Cli Usage
```shell
Usage: directory-json [options]
Converts a directory structure into JSON
Options:
-v, --version output the version number
-c, --cwd Relative from this directory
-r, --recurse Recurse sub-directories
-l, --hash-length Length of the hash to remove from key names
-p, --prettify Prettify the JSON output
-h, --help output usage information
```
## Options
#### options.cwd
Type: `String`
Default value: `'.'`
Paths are relative from this directory.
#### options.recurse
Type: `Boolean`
Default value: `true`
Whether to recurse through sub-directories.
#### options.hashLength
Type: `Number`
Default value: `0`
Length of the hash to remove from key names.
#### options.prettify
Type: `Boolean`
Default value: `false`
Whether to prettify the JSON output.
## Output
```javascript
{
"file1": "file1.txt",
"folder": {
"file2": "folder/file2.txt",
"file3": "folder/file3.txt"
}
}
```