From 7db1671db8d9a39a66c4675543245215b652cd0e Mon Sep 17 00:00:00 2001 From: Maximilian Ertl Date: Thu, 14 Apr 2022 17:17:01 +0200 Subject: [PATCH] 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. --- src/index.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/index.js b/src/index.js index ae788857..a632b9cf 100755 --- a/src/index.js +++ b/src/index.js @@ -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