From d0d8e9c761ac4feba5e958b80a518b9cfd4fbf4b Mon Sep 17 00:00:00 2001 From: Dom Harrington Date: Wed, 6 Feb 2019 11:16:23 -0800 Subject: [PATCH] Add message when a doc hasn't been updated Prior to this, it would console.log `[undefined]` which isn't great! --- lib/docs/index.js | 4 +++- test/docs.test.js | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/docs/index.js b/lib/docs/index.js index f13b9c4e5..aee3f92e8 100644 --- a/lib/docs/index.js +++ b/lib/docs/index.js @@ -59,7 +59,9 @@ exports.run = function({ args, opts }) { } function updateDoc(slug, file, hash, existingDoc) { - if (hash === existingDoc.lastUpdatedHash) return undefined; + if (hash === existingDoc.lastUpdatedHash) { + return `\`${slug}\` not updated. No changes.`; + } return request .put(`${config.host}/api/v1/docs/${slug}`, { json: Object.assign(existingDoc, { diff --git a/test/docs.test.js b/test/docs.test.js index d2d82d089..9831a6dc7 100644 --- a/test/docs.test.js +++ b/test/docs.test.js @@ -91,7 +91,8 @@ describe('docs command', () => { .basicAuth({ user: key }) .reply(200, { category: '5ae9ece93a685f47efb9a97c', slug, lastUpdatedHash: hash }); - return docs(['./test/fixtures/existing-docs'], { key, version }).then(() => { + return docs(['./test/fixtures/existing-docs'], { key, version }).then(([message]) => { + assert.equal(message, '`simple-doc` not updated. No changes.'); getMock.done(); }); });