format-json-files

1.0.6 • Public • Published

format-json-files

npm package

Build Status Dependency Status Coverage Status Known Vulnerabilities XO code style Gitter

Formats json files in the given path. Files have to have the .json extension when a directory is supplied.

When a directory path is supplied format-json-files will search that directory and any sub-directories in a recursive manner and format any .json files found in these directories. If a single file path is supplied, format-json-files will attempt to format the file assuming its a json file.

Installation

Installation is easiest through npm:

npm install format-json-files --save

Usage

format-json-files can be included as a reference.

var formatJsonFiles = require('format-json-files');

formatJsonFiles('./data');

CLI

$ npm install --global format-json-files
$ format-json-files --help

  Usage
    $ format-json-files "<path>"

  Example
    $ format-json-files ".\"

JSON.stringify(targetObj, null, 4); is used to format the json files. fs.readFileSync(targetPath) is used to read the files. fs.writeFileSync(targetPath, serializedObject); is used to write the files. I would have provided options for any or all of these things and more, but I wasn't sure what would be worth spending time on. So if anyone has any requests feel free to file one in github and if I have time I'll take a look.

License

MIT © Mark Rogers

Package Sidebar

Install

npm i format-json-files

Weekly Downloads

12

Version

1.0.6

License

MIT

Unpacked Size

8.16 kB

Total Files

5

Last publish

Collaborators

  • markrogers