Skip to content

Commit

Permalink
fix: Don't ignore login data set via CLI params (regression from #316)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Sirs0ri committed Apr 14, 2022
1 parent b993f82 commit 7db1671
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,20 +79,19 @@ async function main() {
: null;

const parser = (entrypointWithSlash) => {
// parserOptions are used to set headers on the hydra-requests
const parserOptions = {};
if (parserOptions.username && parserOptions.password) {
// options refers to the opts set via the CLI
if (options.username && options.password) {
const encoded = Buffer.from(
`${parserOptions.username}:${parserOptions.password}`
`${options.username}:${options.password}`
).toString("base64");
parserOptions.headers = new Headers();
parserOptions.headers.set("Authorization", `Basic ${encoded}`);
}
if (parserOptions.bearer) {
if (options.bearer) {
parserOptions.headers = new Headers();
parserOptions.headers.set(
"Authorization",
`Bearer ${parserOptions.bearer}`
);
parserOptions.headers.set("Authorization", `Bearer ${options.bearer}`);
}
switch (options.format) {
case "swagger": // deprecated
Expand Down

0 comments on commit 7db1671

Please sign in to comment.