0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-21 13:09:21 +01: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:
Aviv Keller 2024-11-04 14:16:32 -05:00 committed by GitHub
parent d35cde624f
commit 0b58160e2e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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)