Skip to content

Commit 961cbc9

Browse files
avivkelleraduh95
authored andcommitted
tools: use util.parseArgs in lint-md
PR-URL: #55694 Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
1 parent 7aa250a commit 961cbc9

1 file changed

Lines changed: 9 additions & 10 deletions

File tree

‎tools/lint-md/lint-md.mjs‎

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
importfsfrom'fs';
1+
importfsfrom'node:fs';
2+
import{parseArgs}from'node:util';
23

34
import{unified}from'unified';
45
importremarkParsefrom'remark-parse';
@@ -7,20 +8,18 @@ import presetLintNode from 'remark-preset-lint-node';
78
import{read}from'to-vfile';
89
import{reporter}from'vfile-reporter';
910

10-
constpaths=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

1218
if(!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-
letformat=false;
18-
19-
if(paths[0]==='--format'){
20-
paths.shift();
21-
format=true;
22-
}
23-
2423
constlinter=unified()
2524
.use(remarkParse)
2625
.use(presetLintNode)

0 commit comments

Comments
 (0)