gulp-json-tree
v0.1.0
Published
Convert a buffer of files into a JSON representation of the directory structure with contents.
Downloads
7
Maintainers
Readme
gulp-directory-map
Convert a buffer of files into a JSON representation of the directory structure with contents using gulp
Usage
First, install gulp-json-tree
as a development dependency:
npm install --save-dev gulp-json-tree
Then, add it to your gulpfile.js
:
var jsonTree = require("gulp-json-tree");
gulp.src('app/**/*.json')
.pipe(jsonTree({
filename: 'urls.json'
}))
.pipe(gulp.dest('dist'));
Given this directory structure...
app
|_nested-folder-1
|_nested-folder-1-1
|_index.json
|_faq.json
|_index.json
|_nested-folder-2
|_nested-folder-2-1
|_index.json
|_index.json
|_index.json
... this JSON object would be written to dist/urls.json
:
{
"index.html": { ... },
"nested-folder-1": {
"faq.html": { ... },
"index.html": { ... },
"nested-folder-1-1": {
"index.html": { ... }
}
},
"nested-folder-2": {
"index.html": { ... }
}
}
This is useful for mapping out a directory structure after passing files through a pre-processor, generating data to create navigation during build, and more.
API
directory-map(options)
options.filename
Type: String
Default: urls.json
The path to write the directory structure JSON file to.