@@ -513,7 +513,8 @@ test('should print help', async () => {
513
513
Options:
514
514
-c, --color toggle colored output [boolean] [default: true]
515
515
-g, --config path to the config file [string]
516
- --print-config print resolved config [boolean] [default: false]
516
+ --print-config print resolved config
517
+ [string] [choices: "", "text", "json"]
517
518
-d, --cwd directory to execute in
518
519
[string] [default: (Working Directory)]
519
520
-e, --edit read last commit message from the specified file or
@@ -547,14 +548,16 @@ test('should print version', async () => {
547
548
expect ( actual . stdout ) . toMatch ( '@commitlint/cli@' ) ;
548
549
} ) ;
549
550
550
- test ( 'should print config' , async ( ) => {
551
- const cwd = await gitBootstrap ( 'fixtures/default' ) ;
552
- const actual = await cli ( [ '--print-config' , '--no-color' ] , { cwd} ) ( ) ;
553
- const stdout = actual . stdout
554
- . replace ( / ^ { [ ^ \n ] / g, '{\n ' )
555
- . replace ( / [ ^ \n ] } $ / g, '\n}' )
556
- . replace ( / ( h e l p U r l : ) \n [ ] + / , '$1 ' ) ;
557
- expect ( stdout ) . toMatchInlineSnapshot ( `
551
+ describe ( 'should print config' , ( ) => {
552
+ test ( 'should print config when flag is present but without value' , async ( ) => {
553
+ const cwd = await gitBootstrap ( 'fixtures/default' ) ;
554
+ const actual = await cli ( [ '--print-config' , 'text' , '--no-color' ] , { cwd} ) ( ) ;
555
+
556
+ const stdout = actual . stdout
557
+ . replace ( / ^ { [ ^ \n ] / g, '{\n ' )
558
+ . replace ( / [ ^ \n ] } $ / g, '\n}' )
559
+ . replace ( / ( h e l p U r l : ) \n [ ] + / , '$1 ' ) ;
560
+ expect ( stdout ) . toMatchInlineSnapshot ( `
558
561
"{
559
562
extends: [],
560
563
formatter: '@commitlint/format',
@@ -567,6 +570,39 @@ test('should print config', async () => {
567
570
prompt: {}
568
571
}"
569
572
` ) ;
573
+ } ) ;
574
+
575
+ test ( 'should print config when flag has `text` value' , async ( ) => {
576
+ const cwd = await gitBootstrap ( 'fixtures/default' ) ;
577
+ const actual = await cli ( [ '--print-config=text' , '--no-color' ] , { cwd} ) ( ) ;
578
+
579
+ const stdout = actual . stdout
580
+ . replace ( / ^ { [ ^ \n ] / g, '{\n ' )
581
+ . replace ( / [ ^ \n ] } $ / g, '\n}' )
582
+ . replace ( / ( h e l p U r l : ) \n [ ] + / , '$1 ' ) ;
583
+ expect ( stdout ) . toMatchInlineSnapshot ( `
584
+ "{
585
+ extends: [],
586
+ formatter: '@commitlint/format',
587
+ parserPreset: undefined,
588
+ ignores: undefined,
589
+ defaultIgnores: undefined,
590
+ plugins: {},
591
+ rules: { 'type-enum': [ 2, 'never', [ 'foo' ] ] },
592
+ helpUrl: 'https://github.com/conventional-changelog/commitlint/#what-is-commitlint',
593
+ prompt: {}
594
+ }"
595
+ ` ) ;
596
+ } ) ;
597
+
598
+ test ( 'should print config when flag has `json` value' , async ( ) => {
599
+ const cwd = await gitBootstrap ( 'fixtures/default' ) ;
600
+ const actual = await cli ( [ '--print-config=json' , '--no-color' ] , { cwd} ) ( ) ;
601
+
602
+ expect ( actual . stdout ) . toMatchInlineSnapshot (
603
+ `"{"extends":[],"formatter":"@commitlint/format","plugins":{},"rules":{"type-enum":[2,"never",["foo"]]},"helpUrl":"https://github.com/conventional-changelog/commitlint/#what-is-commitlint\","prompt":{}}"`
604
+ ) ;
605
+ } ) ;
570
606
} ) ;
571
607
572
608
async function writePkg ( payload : unknown , options : TestOptions ) {
0 commit comments