directory-to-json
Write a representation of a directory to a JSON
file. Small wrapper
around directory-to-object.
Installation
$ npm install directory-to-json
Usage
const dtj = require('directory-to-json')
dtj('./mydir', './outfile.json', (err) => console.log(err))
API
dto(opts|inPath, outPath, callback)
dtj(path.resolve('./test'), './outfile.json', (err, res) => console.log(res))
// `noDot` ignores files which have a leading `.`
// in the filename.
const opts = {noDot: true, path: path.resolve('./test')}
dto(opts, './outfile.json', (err, res) => console.log(res))
Why?
When parsing several directories of files it's nice to just have to provide a path rather than creating an index object manually. This is useful for creating static sites out of markdown files. Client-side projects can't call a read function dynamically however, so a static file must be created.