directory-to-json

1.3.0 • Public • Published

directory-to-json

NPM version Downloads

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.

See Also

License

MIT

Package Sidebar

Install

npm i directory-to-json

Weekly Downloads

1

Version

1.3.0

License

MIT

Last publish

Collaborators

  • yoshuawuyts