Skip to content

Commit 7db1671

Browse files
committed
fix: Don't ignore login data set via CLI params (regression from #316)
In attempting to fix an empty `options` object overshadowing the options set by the user via CLI, #316 mistakenly adjusted `options.username`, `options.password` and `options.bearer` to be attributes of the newly introduced `parserOptions`. They should, however, still refer to the `options` object that holds all the information previously set via CLI arguments. I also added two comments to make the difference between the two sets of options more clear.
1 parent b993f82 commit 7db1671

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/index.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,20 +79,19 @@ async function main() {
7979
: null;
8080

8181
const parser = (entrypointWithSlash) => {
82+
// parserOptions are used to set headers on the hydra-requests
8283
const parserOptions = {};
83-
if (parserOptions.username && parserOptions.password) {
84+
// options refers to the opts set via the CLI
85+
if (options.username && options.password) {
8486
const encoded = Buffer.from(
85-
`${parserOptions.username}:${parserOptions.password}`
87+
`${options.username}:${options.password}`
8688
).toString("base64");
8789
parserOptions.headers = new Headers();
8890
parserOptions.headers.set("Authorization", `Basic ${encoded}`);
8991
}
90-
if (parserOptions.bearer) {
92+
if (options.bearer) {
9193
parserOptions.headers = new Headers();
92-
parserOptions.headers.set(
93-
"Authorization",
94-
`Bearer ${parserOptions.bearer}`
95-
);
94+
parserOptions.headers.set("Authorization", `Bearer ${options.bearer}`);
9695
}
9796
switch (options.format) {
9897
case "swagger": // deprecated

0 commit comments

Comments
 (0)