git ssb

4+

Dominic / scuttlebot



Commit 0cd472b028e88ceb65e2dfedce1ff1afbe2ab7e9

Use ssb-npm-registry

cel authored on 9/20/2017, 10:10:48 PM
Henry committed on 11/30/2017, 9:46:20 PM
Parent: 176fc9341ed03d9a3b53a036578e7f7e026619e8

Files changed

bin.jschanged
package.jsonchanged
plugins/plugins.jschanged
bin.jsView
@@ -48,8 +48,9 @@
4848 .use(require('./plugins/private'))
4949 .use(require('ssb-query'))
5050 .use(require('ssb-links'))
5151 .use(require('ssb-ws'))
52 + .use(require('ssb-npm-registry'))
5253
5354 // add third-party plugins
5455 require('./plugins/plugins').loadUserPlugins(createSbot, config)
5556
package.jsonView
@@ -62,8 +62,9 @@
6262 "ssb-friends": "^2.3.2",
6363 "ssb-keys": "^7.0.13",
6464 "ssb-links": "^3.0.0",
6565 "ssb-msgs": "~5.2.0",
66 + "ssb-npm-registry": "^1.0.1",
6667 "ssb-query": "^1.0.0",
6768 "ssb-ref": "^2.7.1",
6869 "ssb-ws": "^1.0.3",
6970 "statistics": "^3.0.0",
plugins/plugins.jsView
@@ -99,17 +99,27 @@
9999 // create a tmp directory to install into
100100 var tmpInstallPath = path.join(osenv.tmpdir(), pluginName)
101101 rimraf.sync(tmpInstallPath); mkdirp.sync(tmpInstallPath)
102102
103 + if (this['npm-registry']) this['npm-registry'].getAddress(next)
104 + else next()
105 +
103106 // build args
104107 // --global-style: dont dedup at the top level, gives proper isolation between each plugin
105108 // --loglevel error: dont output warnings, because npm just whines about the lack of a package.json in ~/.ssb
109 +
106110 var args = ['install', from||pluginName, '--global-style', '--loglevel', 'error']
107111 if (dryRun)
108112 args.push('--dry-run')
109113
110- // exec npm
111- var child = spawn('npm', args, { cwd: tmpInstallPath })
114 + function next(err, registryUrl) {
115 + if (err) console.trace(err)
116 +
117 + if (registryUrl)
118 + args.push('--registry', registryUrl)
119 +
120 + // exec npm
121 + var child = spawn('npm', args, { cwd: tmpInstallPath })
112122 .on('close', function (code) {
113123 if (code == 0 && !dryRun) {
114124 var tmpInstallNMPath = path.join(tmpInstallPath, 'node_modules')
115125 var finalInstallNMPath = path.join(installPath, 'node_modules')
@@ -144,8 +154,9 @@
144154 pull.values([new Buffer('Installing "'+pluginName+'"...\n', 'utf-8')]),
145155 many([toPull(child.stdout), toPull(child.stderr)]),
146156 p
147157 ])
158 + }
148159 }, 'string', 'object?'),
149160 uninstall: valid.source(function (pluginName, opts) {
150161 var p = pushable()
151162 if (!pluginName || typeof pluginName !== 'string')

Built with git-ssb-web