1
1
#!/usr/bin/env node
2
2
3
3
import { resolve } from 'node:path' ;
4
- import { argv } from 'node:process' ;
4
+ import { argv , exit } from 'node:process' ;
5
5
6
6
import { Command , Option } from 'commander' ;
7
7
@@ -12,6 +12,8 @@ import generators from '../src/generators/index.mjs';
12
12
import createMarkdownLoader from '../src/loaders/markdown.mjs' ;
13
13
import createMarkdownParser from '../src/parsers/markdown.mjs' ;
14
14
import createNodeReleases from '../src/releases.mjs' ;
15
+ import { Linter } from '../src/linter/index.mjs' ;
16
+ import reporters from '../src/linter/reporters/index.mjs' ;
15
17
16
18
const availableGenerators = Object . keys ( generators ) ;
17
19
@@ -50,6 +52,12 @@ program
50
52
'Set the processing target modes'
51
53
) . choices ( availableGenerators )
52
54
)
55
+ . addOption ( new Option ( '--skip-validation' , 'TODO' ) . default ( false ) )
56
+ . addOption (
57
+ new Option ( '--reporter' , 'TODO' )
58
+ . choices ( Object . keys ( reporters ) )
59
+ . default ( 'console' )
60
+ )
53
61
. parse ( argv ) ;
54
62
55
63
/**
@@ -66,7 +74,17 @@ program
66
74
* @type {Options }
67
75
* @description The return type for values sent to the program from the CLI.
68
76
*/
69
- const { input, output, target = [ ] , version, changelog } = program . opts ( ) ;
77
+ const {
78
+ input,
79
+ output,
80
+ target = [ ] ,
81
+ version,
82
+ changelog,
83
+ skipValidation,
84
+ reporter,
85
+ } = program . opts ( ) ;
86
+
87
+ const linter = skipValidation ? undefined : new Linter ( ) ;
70
88
71
89
const { loadFiles } = createMarkdownLoader ( ) ;
72
90
const { parseApiDocs } = createMarkdownParser ( ) ;
@@ -91,4 +109,13 @@ await runGenerators({
91
109
version : coerce ( version ) ,
92
110
// A list of all Node.js major versions with LTS status
93
111
releases : await getAllMajors ( ) ,
112
+ linter,
94
113
} ) ;
114
+
115
+ if ( linter ) {
116
+ linter . report ( reporter ) ;
117
+
118
+ if ( linter . hasError ) {
119
+ exit ( 1 ) ;
120
+ }
121
+ }
0 commit comments