feat(dev-infra): migrate pullapprove tool to use new logging system (#37232)

Migrate the pullapprove tool in ng-dev to use new logging system rather
than directly calling console.* to create a better experience
for users.

PR Close #37232
This commit is contained in:
Joey Perrott
2020-05-20 14:41:44 -07:00
committed by Matias Niemelä
parent 9b3ca19675
commit 367f6fe12d
3 changed files with 35 additions and 28 deletions

View File

@ -6,18 +6,19 @@
* found in the LICENSE file at https://angular.io/license
*/
import {info} from '../utils/console';
import {PullApproveGroupResult} from './group';
/** Create logs for each pullapprove group result. */
export function logGroup(group: PullApproveGroupResult, matched = true) {
const conditions = matched ? group.matchedConditions : group.unmatchedConditions;
console.groupCollapsed(`[${group.groupName}]`);
info.group(`[${group.groupName}]`);
if (conditions.length) {
conditions.forEach(matcher => {
const count = matcher.matchedFiles.size;
console.info(`${count} ${count === 1 ? 'match' : 'matches'} - ${matcher.expression}`)
info(`${count} ${count === 1 ? 'match' : 'matches'} - ${matcher.expression}`);
});
console.groupEnd();
info.groupEnd();
}
}
@ -30,7 +31,7 @@ export function logHeader(...params: string[]) {
const rightSpace = fillWidth - leftSpace - headerText.length;
const fill = (count: number, content: string) => content.repeat(count);
console.info(`${fill(fillWidth, '─')}`);
console.info(`${fill(leftSpace, ' ')}${headerText}${fill(rightSpace, ' ')}`);
console.info(`${fill(fillWidth, '─')}`);
info(`${fill(fillWidth, '─')}`);
info(`${fill(leftSpace, ' ')}${headerText}${fill(rightSpace, ' ')}`);
info(`${fill(fillWidth, '─')}`);
}