1.0.1 ā€¢ Published 2 months ago

sort-jsonc-cli v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

sort-jsonc-cli

npm

āœ… CLI for sort JSONC/JSON5 files without mangling comments!

Works with regular JSON files too, of course!

See sort-jsonc for the underlying library.

Usage

sort-jsonc [options] <files>

Options

OptionAliasDescription
--order-oThe preferred order to sort keys as a comma-separated string. Prioritized over --order-file. Keys not in this list will be sorted alphabetically at the end.
--order-file-OPath to a JSON file containing a list of strings in preferred order. Keys not in this list will be sorted alphabetically at the end.
--remove-comments-cWhether to remove comments from the JSON.
--spaces-SNumber of spaces to indent the JSON.
--silent-sWhether to suppress output.
--help-vShow help info.

Examples

Sort a file

$ sort-jsonc sort-jsonc path/to/file.jsonc

Sort multiple files

$ sort-jsonc path/to/file1.jsonc path/to/file2.jsonc

Sort a file by preferred order

$ sort-jsonc sort-jsonc path/to/file.jsonc -o name,version,description

Sort a file by preferred order from a file

$ sort-jsonc sort-jsonc path/to/file.jsonc -O path/to/order.json

Sort a file and remove comments

$ sort-jsonc sort-jsonc path/to/file.jsonc -c