Skip to content

Commit

Permalink
Add message when a doc hasn't been updated
Browse files Browse the repository at this point in the history
Prior to this, it would console.log `[undefined]` which isn't great!
  • Loading branch information
domharrington committed Feb 6, 2019
1 parent bb3a75b commit d0d8e9c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lib/docs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand Down
3 changes: 2 additions & 1 deletion test/docs.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
});
Expand Down

0 comments on commit d0d8e9c

Please sign in to comment.