yaml-sort
sorts YAML files alphabetically.
This tool is basically a tiny wrapper around js-yaml.
(Inspired by yml-sorter)
npm install -g yaml-sort
Usage: yaml-sort [options]
Options:
-i, --input The YAML file(s) which needs to be sorted [array] [default: STDIN]
-o, --output The YAML file to output sorted content to [string] [default: overwrite input file if specified or STDOUT]
-s, --stdout Output the proposed sort to STDOUT only [boolean]
-k, --check Check if the given file(s) is already sorted [boolean]
--indent, --id Indentation width (in spaces) [number] [default: 2]
-e, --encoding Input encoding [choices: "ascii", "utf8", "utf16le"] [default: "utf8"]
-q, --quotingStyle Strings will be quoted using this quoting style [choices: "single", "double"] [default: "single"]
-w, --lineWidth Wrap line width (-1 for unlimited width) [number] [default: 80]
-h, --help Show help [boolean]
--version Show version number [boolean]
Examples:
yaml-sort --input config.yml Sorts alphabetically and overwrites the file config.yml
yaml-sort --input config.yml --lineWidth 100 --stdout Sorts the file config.yml and output result to STDOUT wrapped to 100 columns
yaml-sort --input config.yml --indent 4 --output sorted.yml Indents with 4 spaces and outputs result to file sorted.yml
cat config.yml | yaml-sort Sorts alphabetically from STDIN