git ssb

2+

Dominic / ssb-client



Commit 2ef5acc007ebb7702f358d1dfe780a6ac984047c

support appname as first argument

Dominic Tarr committed on 5/14/2016, 12:04:24 AM
Parent: 768d80bcfc5db9a95bfb4d157a6fb9348f39c756

Files changed

index.jschanged
index.jsView
@@ -1,28 +1,32 @@
11 var path = require('path')
22 var ssbKeys = require('ssb-keys')
3-var config = require('ssb-config')
43 var SecretStack = require('secret-stack')
54 var explain = require('explain-error')
65 var path = require('path')
76 var fs = require('fs')
87
98 var cap =
109 new Buffer('1KHLiKZvAvjbY1ziZEHMXawbCEIM6qwjCDm3VYRan/s=', 'base64')
1110
11+var createConfig = require('ssb-config/inject')
1212
1313 module.exports = function (keys, opts, cb) {
1414 if (typeof keys == 'function') {
1515 cb = keys
1616 keys = null
1717 opts = null
18- }
19- if (typeof opts == 'function') {
18+ }
19+ else if (typeof opts == 'function') {
2020 cb = opts
21- opts = null
21+ opts = keys
22+ keys = null
2223 }
2324
24- keys = keys || ssbKeys.loadOrCreateSync(path.join(config.path, 'secret'))
25+ if(typeof opts === 'string')
26+ opts = createConfig(opts)
27+
28+ keys = keys || ssbKeys.loadOrCreateSync(path.join(opts.path, 'secret'))
2529 opts = opts || {}
2630 opts.host = opts.host || 'localhost'
2731 opts.port = opts.port || config.port
2832 opts.key = opts.key || keys.id
@@ -31,9 +35,9 @@
3135
3236 var manifest = opts.manifest || (function () {
3337 try {
3438 return JSON.parse(fs.readFileSync(
35- path.join(config.path, 'manifest.json')
39+ path.join(opts.path, 'manifest.json')
3640 ))
3741 } catch (err) {
3842 throw explain(err, 'could not load manifest file')
3943 }
@@ -43,4 +47,5 @@
4347 if(err) err = explain(err, 'could not connect to sbot')
4448 cb(err, sbot)
4549 })
4650 }
51+

Built with git-ssb-web