Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement new --active-only option #23

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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