Skip to content

Commit 96b9b49

Browse files
authored
Unset line width to allow arbitrarily long lines (#168)
* Increase line width to avoid reformatting yaml * Add tests * Set unlimited lineWidth
1 parent b797dee commit 96b9b49

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

ts/kpt-functions/src/io.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ const YAML_STYLE: DumpOptions = {
3636
// Either reason about not having 'undefined' in all cases OR
3737
// only skip 'undefined'.
3838
skipInvalid: true,
39+
// unset lineWidth from default of 80 to avoid reformatting
40+
lineWidth: -1,
3941
};
4042

4143
/**

ts/kpt-functions/src/io_test.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,35 @@ results:
466466
severity: error
467467
`);
468468
});
469+
470+
it('preserves long lines', () => {
471+
const result = stringify(
472+
new Configs([
473+
{
474+
apiVersion: 'v1',
475+
kind: 'Namespace',
476+
metadata: {
477+
name:
478+
'0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789',
479+
},
480+
},
481+
]),
482+
FileFormat.YAML
483+
);
484+
485+
expect(result).toEqual(
486+
`apiVersion: v1
487+
kind: ResourceList
488+
metadata:
489+
name: output
490+
items:
491+
- apiVersion: v1
492+
kind: Namespace
493+
metadata:
494+
name: 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
495+
`
496+
);
497+
});
469498
});
470499

471500
describe('in JSON format', () => {

0 commit comments

Comments
 (0)