check-openapi: Modernize yargs usage.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2024-04-08 16:29:37 -07:00 committed by Anders Kaseorg
parent 7d6c5beb19
commit 15cec69995
1 changed files with 8 additions and 5 deletions

View File

@ -9,12 +9,15 @@ const ExampleValidator = require("openapi-examples-validator");
const Prettier = require("prettier"); const Prettier = require("prettier");
const SwaggerParser = require("swagger-parser"); const SwaggerParser = require("swagger-parser");
const {Composer, CST, LineCounter, Parser, Scalar, YAMLMap, YAMLSeq, visit} = require("yaml"); const {Composer, CST, LineCounter, Parser, Scalar, YAMLMap, YAMLSeq, visit} = require("yaml");
const yargs = require("yargs"); const {hideBin} = require("yargs/helpers");
const yargs = require("yargs/yargs");
const {argv} = yargs.option("fix", { const argv = yargs(hideBin(process.argv))
type: "boolean", .option("fix", {
description: "Automatically fix some problems", type: "boolean",
}); description: "Automatically fix some problems",
})
.parse();
async function checkFile(file) { async function checkFile(file) {
const yaml = await fs.promises.readFile(file, "utf8"); const yaml = await fs.promises.readFile(file, "utf8");