Skip to content

Commit

Permalink
fix(logger): Imply verbose mode when log level is debug or trace
Browse files Browse the repository at this point in the history
  • Loading branch information
TimothyJones committed Jan 29, 2021
1 parent 513a60d commit 814d4fb
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 4 deletions.
6 changes: 5 additions & 1 deletion src/can-deploy.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import q = require('q');
import logger from './logger';
import logger, { verboseIsImplied } from './logger';
import spawn from './spawn';
import pactStandalone from './pact-standalone';
import { PACT_NODE_NO_VALUE } from './spawn';
Expand Down Expand Up @@ -77,6 +77,10 @@ export class CanDeploy {
options.pactBrokerPassword !== undefined &&
checkTypes.assert.string(options.pactBrokerPassword);

if (options.verbose === undefined && verboseIsImplied()) {
options.verbose = true;
}

if (
(options.pactBrokerUsername && !options.pactBrokerPassword) ||
(options.pactBrokerPassword && !options.pactBrokerUsername)
Expand Down
3 changes: 3 additions & 0 deletions src/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,7 @@ export const setLogLevel = (
return logger.levels.values[logger.level];
};

export const verboseIsImplied = (): boolean =>
logger.level === 'trace' || logger.level === 'debug';

export default logger;
6 changes: 5 additions & 1 deletion src/publisher.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import q = require('q');
import path = require('path');
import fs = require('fs');
import logger from './logger';
import logger, { verboseIsImplied } from './logger';
import spawn from './spawn';
import { DEFAULT_ARG } from './spawn';
import { deprecate } from 'util';
Expand Down Expand Up @@ -77,6 +77,10 @@ export class Publisher {
checkTypes.assert.string(options.pactBrokerPassword);
}

if (options.verbose === undefined && verboseIsImplied()) {
options.verbose = true;
}

if (
(options.pactBrokerUsername && !options.pactBrokerPassword) ||
(options.pactBrokerPassword && !options.pactBrokerUsername)
Expand Down
2 changes: 1 addition & 1 deletion src/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import fs = require('fs');
import events = require('events');
import http = require('request');
import q = require('q');
import logger, { setLogLevel } from './logger';
import logger, { setLogLevel } from './logger';
import spawn, { CliVerbOptions } from './spawn';
import { ChildProcess } from 'child_process';
import mkdirp = require('mkdirp');
Expand Down
6 changes: 5 additions & 1 deletion src/verifier.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import path = require('path');
import url = require('url');
import logger from './logger';
import logger, { verboseIsImplied } from './logger';
import spawn from './spawn';
import { DEFAULT_ARG } from './spawn';
import q = require('q');
Expand Down Expand Up @@ -222,6 +222,10 @@ export class Verifier {
}
}

if (options.verbose === undefined && verboseIsImplied()) {
options.verbose = true;
}

if (options.out) {
checkTypes.assert.string(options.out);
}
Expand Down

0 comments on commit 814d4fb

Please sign in to comment.