Commit 2ef5acc007ebb7702f358d1dfe780a6ac984047c
support appname as first argument
Dominic Tarr committed on 5/14/2016, 12:04:24 AMParent: 768d80bcfc5db9a95bfb4d157a6fb9348f39c756
Files changed
index.js | changed |
index.js | ||
---|---|---|
@@ -1,28 +1,32 @@ | ||
1 | 1 | var path = require('path') |
2 | 2 | var ssbKeys = require('ssb-keys') |
3 | -var config = require('ssb-config') | |
4 | 3 | var SecretStack = require('secret-stack') |
5 | 4 | var explain = require('explain-error') |
6 | 5 | var path = require('path') |
7 | 6 | var fs = require('fs') |
8 | 7 | |
9 | 8 | var cap = |
10 | 9 | new Buffer('1KHLiKZvAvjbY1ziZEHMXawbCEIM6qwjCDm3VYRan/s=', 'base64') |
11 | 10 | |
11 | +var createConfig = require('ssb-config/inject') | |
12 | 12 | |
13 | 13 | module.exports = function (keys, opts, cb) { |
14 | 14 | if (typeof keys == 'function') { |
15 | 15 | cb = keys |
16 | 16 | keys = null |
17 | 17 | opts = null |
18 | - } | |
19 | - if (typeof opts == 'function') { | |
18 | + } | |
19 | + else if (typeof opts == 'function') { | |
20 | 20 | cb = opts |
21 | - opts = null | |
21 | + opts = keys | |
22 | + keys = null | |
22 | 23 | } |
23 | 24 | |
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')) | |
25 | 29 | opts = opts || {} |
26 | 30 | opts.host = opts.host || 'localhost' |
27 | 31 | opts.port = opts.port || config.port |
28 | 32 | opts.key = opts.key || keys.id |
@@ -31,9 +35,9 @@ | ||
31 | 35 | |
32 | 36 | var manifest = opts.manifest || (function () { |
33 | 37 | try { |
34 | 38 | return JSON.parse(fs.readFileSync( |
35 | - path.join(config.path, 'manifest.json') | |
39 | + path.join(opts.path, 'manifest.json') | |
36 | 40 | )) |
37 | 41 | } catch (err) { |
38 | 42 | throw explain(err, 'could not load manifest file') |
39 | 43 | } |
@@ -43,4 +47,5 @@ | ||
43 | 47 | if(err) err = explain(err, 'could not connect to sbot') |
44 | 48 | cb(err, sbot) |
45 | 49 | }) |
46 | 50 | } |
51 | + |
Built with git-ssb-web