mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
tools: use util.parseArgs
in lint-md
PR-URL: https://github.com/nodejs/node/pull/55694 Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
This commit is contained in:
parent
d35cde624f
commit
0b58160e2e
@ -1,4 +1,5 @@
|
||||
import fs from 'fs';
|
||||
import fs from 'node:fs';
|
||||
import { parseArgs } from 'node:util';
|
||||
|
||||
import { unified } from 'unified';
|
||||
import remarkParse from 'remark-parse';
|
||||
@ -7,20 +8,18 @@ import presetLintNode from 'remark-preset-lint-node';
|
||||
import { read } from 'to-vfile';
|
||||
import { reporter } from 'vfile-reporter';
|
||||
|
||||
const paths = process.argv.slice(2);
|
||||
const { values: { format }, positionals: paths } = parseArgs({
|
||||
options: {
|
||||
format: { type: 'boolean', default: false },
|
||||
},
|
||||
allowPositionals: true,
|
||||
});
|
||||
|
||||
if (!paths.length) {
|
||||
console.error('Usage: lint-md.mjs <path> [<path> ...]');
|
||||
console.error('Usage: lint-md.mjs [--format] <path> [<path> ...]');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
let format = false;
|
||||
|
||||
if (paths[0] === '--format') {
|
||||
paths.shift();
|
||||
format = true;
|
||||
}
|
||||
|
||||
const linter = unified()
|
||||
.use(remarkParse)
|
||||
.use(presetLintNode)
|
||||
|
Loading…
Reference in New Issue
Block a user