Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Options:
-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"]
-q, --quoteStyle Strings will be quoted using this quote style [choices: "single", "double"] [default: "single"]
-f, --forceQuotes Force quotes around all strings [boolean]
-w, --lineWidth Wrap line width (-1 for unlimited width) [number] [default: 80]
-h, --help Show help [boolean]
Expand Down
14 changes: 7 additions & 7 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ test('CLI w/ arg', (t) => {
proc.end()
})

test('CLI quoting style single', (t) => {
const proc = spawn(t, '../yaml-sort.js --input test-edges.yml --stdout --quotingStyle single', opts)
test('CLI quote style single', (t) => {
const proc = spawn(t, '../yaml-sort.js --input test-edges.yml --stdout --quoteStyle single', opts)
proc.exitCode(0)
proc.stdout.match('a: Lorem ipsum dolor sit amet, consectetur adipiscing elit...\n' +
'b:\n' +
Expand All @@ -60,8 +60,8 @@ test('CLI quoting style single', (t) => {
proc.end()
})

test('CLI quoting style double', (t) => {
const proc = spawn(t, '../yaml-sort.js --input test-edges.yml --stdout --quotingStyle double', opts)
test('CLI quote style double', (t) => {
const proc = spawn(t, '../yaml-sort.js --input test-edges.yml --stdout --quoteStyle double', opts)
proc.exitCode(0)
proc.stdout.match('a: Lorem ipsum dolor sit amet, consectetur adipiscing elit...\n' +
'b:\n' +
Expand Down Expand Up @@ -248,7 +248,7 @@ test('CLI --check --stdout FAIL', (t) => {
})

test('CLI multiple YAML documents with single quotes', (t) => {
const proc = spawn(t, '../yaml-sort.js --input test-multiple.yml --stdout --quotingStyle single --forceQuotes', opts)
const proc = spawn(t, '../yaml-sort.js --input test-multiple.yml --stdout --quoteStyle single --forceQuotes', opts)
proc.exitCode(0)
proc.stdout.match(
'---\n' +
Expand All @@ -266,7 +266,7 @@ test('CLI multiple YAML documents with single quotes', (t) => {
})

test('CLI multiple YAML documents with double quotes', (t) => {
const proc = spawn(t, '../yaml-sort.js --input test-multiple.yml --stdout --quotingStyle double --forceQuotes', opts)
const proc = spawn(t, '../yaml-sort.js --input test-multiple.yml --stdout --quoteStyle double --forceQuotes', opts)
proc.exitCode(0)
proc.stdout.match(
'---\n' +
Expand All @@ -284,7 +284,7 @@ test('CLI multiple YAML documents with double quotes', (t) => {
})

test('CLI multiple YAML documents --check FAIL', (t) => {
const proc = spawn(t, '../yaml-sort.js --input test-multiple-unsorted.yml --check --quotingStyle single --forceQuotes', opts)
const proc = spawn(t, '../yaml-sort.js --input test-multiple-unsorted.yml --check --quoteStyle single --forceQuotes', opts)
proc.exitCode(1)
proc.stdout.match('')
proc.stderr.match('\'test-multiple-unsorted.yml\' is not sorted and/or formatted (indent, line width).\n')
Expand Down
6 changes: 3 additions & 3 deletions yaml-sort.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ const argv = yargs(hideBin(process.argv))
describe: 'Input encoding',
choices: ['ascii', 'utf8', 'utf16le']
})
.option('quotingStyle', {
.option('quoteStyle', {
alias: 'q',
default: 'single',
describe: 'Strings will be quoted using this quoting style',
describe: 'Strings will be quoted using this quote style',
choices: ['single', 'double']
})
.option('forceQuotes', {
Expand Down Expand Up @@ -106,7 +106,7 @@ argv.input.forEach((file) => {
sortKeys: true,
indent: argv.indent,
lineWidth: argv.lineWidth,
quoteStyle: argv.quotingStyle,
quoteStyle: argv.quoteStyle,
forceQuotes: argv.forceQuotes
}))

Expand Down