-
Notifications
You must be signed in to change notification settings - Fork 621
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
parseArgs duplicates collected + aliased arguments #4481
Comments
This issue belongs in https://github.com/denoland/deno_std |
This seems to have started from #4189 The example test case passes with import { parseArgs } from "https://deno.land/[email protected]/cli/parse_args.ts";
import { assertEquals } from "https://deno.land/[email protected]/assert/mod.ts";
Deno.test("collect with alias", () => {
const args = ["--header", "abc", "--header", "def"];
const parsed = parseArgs(args, {
collect: ["header"],
alias: {
H: "header",
},
});
assertEquals(parsed.header, ["abc", "def"])
}) I'd suggest we should revert #4189 |
I think I found the bug. The Map(2) {
"H" => Set(1) { "header" },
"header" => Set(2) { "H", "header" }
} This is fixed by filtering out the key. before: const set = new Set([key, ...aliases]);
aliases.forEach((alias) => aliasMap.set(alias, set)); after: aliases.forEach((alias) => aliasMap.set(alias, new Set([key, ...aliases.filter((it) => it !== alias)]))); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Version: Deno 1.41.2
The
parseArgs
function from https://deno.land/std/cli/parse_args.ts seems to duplicatecollect
arguments when an alias is part of the definition.This affects the file_server with the
--header
option; this results in HTTP headers being written twice.Minimal test case to repro:
Output:
Removing the alias makes things work as expected.
The text was updated successfully, but these errors were encountered: