11#!/usr/bin/env node
22
33import { resolve } from 'node:path' ;
4- import { argv } from 'node:process' ;
4+ import { argv , exit } from 'node:process' ;
55
66import { Command , Option } from 'commander' ;
77
@@ -12,6 +12,8 @@ import generators from '../src/generators/index.mjs';
1212import createLoader from '../src/loader.mjs' ;
1313import createParser from '../src/parser.mjs' ;
1414import createNodeReleases from '../src/releases.mjs' ;
15+ import { Linter } from '../src/linter/index.mjs' ;
16+ import reporters from '../src/linter/reporters/index.mjs' ;
1517
1618const availableGenerators = Object . keys ( generators ) ;
1719
@@ -50,6 +52,12 @@ program
5052 'Set the processing target modes'
5153 ) . choices ( availableGenerators )
5254 )
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+ )
5361 . parse ( argv ) ;
5462
5563/**
@@ -66,10 +74,20 @@ program
6674 * @type {Options }
6775 * @description The return type for values sent to the program from the CLI.
6876 */
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 ( ) ;
7088
7189const { loadFiles } = createLoader ( ) ;
72- const { parseApiDocs } = createParser ( ) ;
90+ const { parseApiDocs } = createParser ( linter ) ;
7391
7492const apiDocFiles = loadFiles ( input ) ;
7593
@@ -89,4 +107,13 @@ await runGenerators({
89107 version : coerce ( version ) ,
90108 // A list of all Node.js major versions with LTS status
91109 releases : await getAllMajors ( ) ,
110+ linter,
92111} ) ;
112+
113+ if ( linter ) {
114+ linter . report ( reporter ) ;
115+
116+ if ( linter . hasError ) {
117+ exit ( 1 ) ;
118+ }
119+ }
0 commit comments