Commit de92553986e36c8aa555fb0a529a98913b109777
fixes for configuration
andre alves garzia committed on 6/29/2018, 1:26:43 AMParent: 13ce65e0e17ef86467d82e99ecce021463cc9485
Files changed
host-app.js | changed |
host-app.js | ||
---|---|---|
@@ -2,10 +2,12 @@ | ||
2 | 2 … | const nativeMessage = require('chrome-native-messaging') |
3 | 3 … | const { spawn } = require('child_process') |
4 | 4 … | const path = require('path') |
5 | 5 … | const fs = require('fs') |
6 | -const home = require('os').homedir() | |
6 … | +const config = require('ssb-config/inject')(process.env.ssb_appname) | |
7 | 7 … | |
8 … | +const pathToSecret = path.join(config.path, 'secret') | |
9 … | + | |
8 | 10 … | const input = new nativeMessage.Input() |
9 | 11 … | const transform = new nativeMessage.Transform((msg, push, done) => { |
10 | 12 … | getReplyFor(msg, data => { |
11 | 13 … | push(data) |
@@ -15,11 +17,11 @@ | ||
15 | 17 … | const output = new nativeMessage.Output() |
16 | 18 … | |
17 | 19 … | const getConfig = () => { |
18 | 20 … | try { |
19 | - let secret = fs.readFileSync(`${home}/.ssb/secret`, "utf8") | |
21 … | + let secret = fs.readFileSync(pathToSecret, "utf8") | |
20 | 22 … | let keys = JSON.parse(secret.replace(/#[^\n]*/g, '')) |
21 | - let manifest = JSON.parse(fs.readFileSync(`${home}/.ssb/manifest.json`)) | |
23 … | + let manifest = JSON.parse(fs.readFileSync(path.join(config.path, 'manifest.json'))) | |
22 | 24 … | let remote = "ws://localhost:8989~shs:" + keys.id.substring(1, keys.id.indexOf('.')) |
23 | 25 … | return { type: 'config', keys: keys, manifest: manifest, remote: remote, secret: secret } |
24 | 26 … | } catch (n) { |
25 | 27 … | return { type: 'exception', msg: n.message } |
@@ -58,11 +60,11 @@ | ||
58 | 60 … | cb({ type: 'shutdown', msg: 'stopping server' }) |
59 | 61 … | process.exit(1) |
60 | 62 … | } |
61 | 63 … | case 'get-config': { |
62 | - let secretRaw = fs.readFileSync(`${home}/.ssb/secret`) | |
64 … | + let secretRaw = fs.readFileSync(pathToSecret) | |
63 | 65 … | let keys = JSON.parse(secret.replace(/#[^\n]*/g, '')) |
64 | - let manifest = JSON.parse(fs.readFileSync(`${home}/.ssb/manifest.json`)) | |
66 … | + let manifest = JSON.parse(fs.readFileSync(path.join(config.path, 'manifest.json'))) | |
65 | 67 … | let remote = "ws://localhost:8989~shs:" + keys.id.substring(1, keys.id.indexOf('.')) |
66 | 68 … | |
67 | 69 … | cb({ type: 'config', keys, manifest, remote }) |
68 | 70 … | } |
Built with git-ssb-web