Commit 0b58160 Aviv Keller
authored
1 parent d35cde6 commit 0b58160 Copy full SHA for 0b58160
File tree 1 file changed +9
-10
lines changed
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' ;
2
3
3
4
import { unified } from 'unified' ;
4
5
import remarkParse from 'remark-parse' ;
@@ -7,20 +8,18 @@ import presetLintNode from 'remark-preset-lint-node';
7
8
import { read } from 'to-vfile' ;
8
9
import { reporter } from 'vfile-reporter' ;
9
10
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
+ } ) ;
11
17
12
18
if ( ! paths . length ) {
13
- console . error ( 'Usage: lint-md.mjs <path> [<path> ...]' ) ;
19
+ console . error ( 'Usage: lint-md.mjs [--format] <path> [<path> ...]' ) ;
14
20
process . exit ( 1 ) ;
15
21
}
16
22
17
- let format = false ;
18
-
19
- if ( paths [ 0 ] === '--format' ) {
20
- paths . shift ( ) ;
21
- format = true ;
22
- }
23
-
24
23
const linter = unified ( )
25
24
. use ( remarkParse )
26
25
. use ( presetLintNode )
You can’t perform that action at this time.
0 commit comments