git ssb

16+

cel / patchfoo



Tree: 34c15f1724e91ad281c7fe91b530cc919c9289e0

Files: 34c15f1724e91ad281c7fe91b530cc919c9289e0 / enable-plugin.js

816 bytesRaw
1// Work around broken plugins.enable RPC method
2
3var fs = require('fs')
4var path = require('path')
5
6var pluginName = require('./package').name
7
8var ssbAppname = process.env.ssb_appname || 'ssb'
9var ssbPath = process.env.ssb_path ||
10 path.join(require('os').homedir(), '.' + ssbAppname)
11var confPath = path.join(ssbPath, 'config')
12var confPathTmp = confPath + '~'
13var confData = fs.existsSync(confPath)
14 ? fs.readFileSync(confPath, 'utf8')
15 : 'null'
16var conf = JSON.parse(confData) || {}
17
18var plugins = conf.plugins || (conf.plugins = {})
19if (plugins[pluginName]) {
20 console.log(pluginName + ' already enabled')
21 process.exit(0)
22}
23plugins[pluginName] = true
24
25fs.writeFileSync(confPathTmp, JSON.stringify(conf, 0, 2))
26fs.renameSync(confPathTmp, confPath)
27console.log(pluginName + ' enabled. Restart ssb-server.')
28

Built with git-ssb-web