forked from nodeca/js-yaml
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add "noArrayIndent" option (nodeca#461)
Addresses issue nodeca#432 by adding a `noArrayIndent` option to optionally not add an extra level of indentation to array elements. When `noArrayIndent` option is set to `false` (or not provided), output is: ``` array: - a - b - c ``` When `noArrayIndent` option is set to `true`, output is: ``` array: - a - b - c ``` This helps avoid diffs when parsing, modifying, and generating valid yaml that does *not* use extra indentation for arrays.
- Loading branch information
Showing
3 changed files
with
33 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
'use strict'; | ||
|
||
|
||
var assert = require('assert'); | ||
var yaml = require('../../'); | ||
|
||
|
||
test('should indent arrays an extra level by default', function () { | ||
var output = yaml.safeDump({ array: [ 'a', 'b' ] }); | ||
var expected = 'array:\n - a\n - b\n'; | ||
assert.strictEqual(output, expected); | ||
}); | ||
|
||
test('should not indent arrays an extra level when disabled', function () { | ||
var output = yaml.safeDump({ array: [ 'a', 'b' ] }, { noArrayIndent: true }); | ||
var expected = 'array:\n- a\n- b\n'; | ||
assert.strictEqual(output, expected); | ||
}); |