File tree Expand file tree Collapse file tree 1 file changed +9
-10
lines changed Expand file tree Collapse file tree 1 file changed +9
-10
lines changed Original file line number Diff line number Diff line change 1- import fs from 'fs' ;
1+ import fs from 'node:fs' ;
2+ import { parseArgs } from 'node:util' ;
23
34import { unified } from 'unified' ;
45import remarkParse from 'remark-parse' ;
@@ -7,20 +8,18 @@ import presetLintNode from 'remark-preset-lint-node';
78import { read } from 'to-vfile' ;
89import { reporter } from 'vfile-reporter' ;
910
10- const paths = process . argv . slice ( 2 ) ;
11+ const { values : { format } , positionals : paths } = parseArgs ( {
12+ options : {
13+ format : { type : 'boolean' , default : false } ,
14+ } ,
15+ allowPositionals : true ,
16+ } ) ;
1117
1218if ( ! paths . length ) {
13- console . error ( 'Usage: lint-md.mjs <path> [<path> ...]' ) ;
19+ console . error ( 'Usage: lint-md.mjs [--format] <path> [<path> ...]' ) ;
1420 process . exit ( 1 ) ;
1521}
1622
17- let format = false ;
18-
19- if ( paths [ 0 ] === '--format' ) {
20- paths . shift ( ) ;
21- format = true ;
22- }
23-
2423const linter = unified ( )
2524 . use ( remarkParse )
2625 . use ( presetLintNode )
You can’t perform that action at this time.
0 commit comments