From 47a922112154cbc356eccd14c6e4f23ed668c322 Mon Sep 17 00:00:00 2001 From: cel Date: Sat, 21 Apr 2018 21:19:09 -1000 Subject: Include ssb-npm - Serve ssb-npm-registry requests under /npm-registry - Show install command for npm-packages messages --- lib/render-msg.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'lib/render-msg.js') diff --git a/lib/render-msg.js b/lib/render-msg.js index b4ba87a..684ea40 100644 --- a/lib/render-msg.js +++ b/lib/render-msg.js @@ -1111,12 +1111,24 @@ RenderMsg.prototype.npmPackages = function (cb) { function renderIdLink(id) { return [h('a', {href: self.toUrl(id)}, truncate(id, 8)), ' '] } + var singlePkg = self.c.mentions + && self.c.mentions.length === 1 + && self.c.mentions[0] + var m = singlePkg && /^npm:(.*?):(.*?):/.exec(singlePkg.name) + var singlePkgSpec = m && (m[1] + (m[2] ? '@' + m[2] : '')) self.render.npmPackageMentions(self.c.mentions, function (err, el) { if (err) return cb(err) var dependencyLinks = u.toArray(self.c.dependencyBranch) var versionLinks = u.toArray(self.c.versionBranch) self.wrap(h('div', [ el, + singlePkg ? h('p', + h('code', + 'npm install --registry=' + + 'http://' + self.app.host + ':' + self.app.port + + '/npm-registry/' + encodeURIComponent(self.msg.key) + ' ' + + singlePkgSpec), + ) : '', dependencyLinks.length ? h('div', 'dependencies via: ', dependencyLinks.map(renderIdLink) ) : '', -- cgit v1.2.3