format-json-files

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

Usage no npm install needed!

<script type="module">
  import formatJsonFiles from 'https://cdn.skypack.dev/format-json-files';
</script>

README

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