Skip to content

Commit

Permalink
chore: allow use of env vars if set
Browse files Browse the repository at this point in the history
  • Loading branch information
YOU54F committed Oct 1, 2024
1 parent f42f3ed commit 41621dc
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,13 @@ If the pact broker has basic auth enabled, pass a --user option with username an
)
.action(async (swagger, mock, options) => {
try {
if (!options.user && process.env.PACT_BROKER_USERNAME != '' && process.env.PACT_BROKER_PASSWORD != '') {
if (
options.user == undefined &&
process.env.PACT_BROKER_USERNAME != undefined &&
process.env.PACT_BROKER_PASSWORD != undefined
) {
options.user = process.env.PACT_BROKER_USERNAME + ':' + process.env.PACT_BROKER_PASSWORD;
} else if (!options.token && process.env.PACT_BROKER_TOKEN != '') {
} else if (options.token == undefined && process.env.PACT_BROKER_TOKEN != undefined) {
options.token = process.env.PACT_BROKER_TOKEN;
}
const swaggerMockValidator = SwaggerMockValidatorFactory.create(options.user ?? options.token);
Expand Down

0 comments on commit 41621dc

Please sign in to comment.