sort-jsonc-cli

1.0.2 • Public • Published

sort-jsonc-cli

npm

✅ CLI for sort JSONC 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

Option Alias Description
--order -o The 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 -O Path 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 -c Whether to remove comments from the JSON.
--spaces -S Number of spaces to indent the JSON.
--silent -s Whether to suppress output.
--help -v Show 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

/sort-jsonc-cli/

    Package Sidebar

    Install

    npm i sort-jsonc-cli

    Weekly Downloads

    7

    Version

    1.0.2

    License

    MIT

    Unpacked Size

    28.5 kB

    Total Files

    8

    Last publish

    Collaborators

    • duniul