From d96c42c6804052c6ea48b6833b6d8b110d3baad8 Mon Sep 17 00:00:00 2001 From: cel Date: Sun, 18 Jun 2017 08:29:27 -1000 Subject: Hide npm-publish author if it is same as message author --- lib/render-msg.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/render-msg.js b/lib/render-msg.js index 4374165..a968702 100644 --- a/lib/render-msg.js +++ b/lib/render-msg.js @@ -862,6 +862,16 @@ function asNpmReadme(readme) { return u.ifString(readme) } +function singleValue(obj) { + if (!obj || typeof obj !== 'object') return obj + var keys = Object.keys(obj) + if (keys.length === 1) return obj[keys[0]] +} + +function ifDifferent(obj, value) { + if (singleValue(obj) !== value) return obj +} + RenderMsg.prototype.npmPublish = function (cb) { var self = this var render = self.render @@ -898,7 +908,7 @@ RenderMsg.prototype.npmPublish = function (cb) { versions.map(function (version, i) { var release = pkg.versions[version] || {} var license = u.ifString(release.license) - var author = release.author + var author = ifDifferent(release.author, self.msg.value.author) var description = u.ifString(release.description) var readme = asNpmReadme(release.readme) var keywords = u.toArray(release.keywords).map(u.ifString) -- cgit v1.2.3