Skip to content
This repository has been archived by the owner on Nov 6, 2023. It is now read-only.

Commit

Permalink
figure out the list based on the hints only
Browse files Browse the repository at this point in the history
  • Loading branch information
yanick committed Oct 24, 2021
1 parent ce7df29 commit 73d6401
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
3 changes: 3 additions & 0 deletions examples/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@ const hints = {

report.info('The same list with hints');
report.list('dunno', someList, hints);

report.info('The same list with just the hints');
report.list('just the hints', hints);
2 changes: 1 addition & 1 deletion src/reporters/base-reporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ export default class BaseReporter {
}

// TODO
list(key: string, items: Array<string>, hints?: Object) {}
list(key: string, items: Array<string>|Object, hints?: Object) {}

// Outputs basic tree structure to console
tree(key: string, obj: Trees, {force = false}: {force?: boolean} = {}) {}
Expand Down
8 changes: 7 additions & 1 deletion src/reporters/console/console-reporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,13 @@ export default class ConsoleReporter extends BaseReporter {
this.log(String(value), {force: true});
}

list(key: string, items: Array<string>, hints?: Object) {
list(key: string, items: Array<string>|Object, hints?: Object) {

if( !Array.isArray(items) ) {
hints = items;
items = Object.keys(hints);
}

const gutterWidth = (this._lastCategorySize || 2) - 1;

if (hints) {
Expand Down

0 comments on commit 73d6401

Please sign in to comment.