Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ module.exports = {
return context.commandOptions.amount || 10;
},

activeOnly: function(context) {
return context.commandOptions.activeOnly;
},

revisions: function(context) {
return context.revisions;
}
Expand All @@ -31,6 +35,12 @@ module.exports = {

revisions = revisions.slice(0, this.readConfig("amount"));

if (this.readConfig('activeOnly')) {
revisions = revisions.filter(function(revision) {
return revision.active;
});
}

var hasRevisionData = revisions.reduce(function(prev, current) {
return !prev ? false : !!current.revisionData;
}, true);
Expand Down
13 changes: 13 additions & 0 deletions tests/index-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,19 @@ describe('displayRevisions plugin', function() {
assert.equal(messages.length, 3);
});

it('lists only the active revision when specified', function() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
it('lists only the active revision when specified', function() {
it('lists only the active revisions when specified', function() {

context.commandOptions.activeOnly = true;
plugin.displayRevisions(context);
var messages = mockUi.messages.reduce(function(previous, current) {
if (current.indexOf("rev:") !== -1) {
previous.push(current);
}

return previous;
}, []);
assert.equal(messages.length, 1);
});

it('skips unset keys', function() {
plugin.displayRevisions(context);
var messages = mockUi.messages.reduce(function(previous, current) {
Expand Down