From 2632b1e6363ce6bcf31386efa6cdbf4a1569461b Mon Sep 17 00:00:00 2001 From: Kelly Selden Date: Mon, 30 Mar 2020 09:42:28 +0100 Subject: [PATCH] implement new --active-only option --- index.js | 10 ++++++++++ tests/index-test.js | 13 +++++++++++++ 2 files changed, 23 insertions(+) diff --git a/index.js b/index.js index 7106757..47eb2dc 100644 --- a/index.js +++ b/index.js @@ -16,6 +16,10 @@ module.exports = { return context.commandOptions.amount || 10; }, + activeOnly: function(context) { + return context.commandOptions.activeOnly; + }, + revisions: function(context) { return context.revisions; } @@ -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); diff --git a/tests/index-test.js b/tests/index-test.js index e4028ca..ee15af9 100644 --- a/tests/index-test.js +++ b/tests/index-test.js @@ -186,6 +186,19 @@ describe('displayRevisions plugin', function() { assert.equal(messages.length, 3); }); + it('lists only the active revision 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) {