git ssb

10+

Matt McKegg / patchwork



Commit 322cf9527ab94f96536f92a63ad982f647e1f6b9

Add support for custom ssb path

Peter Squicciarini committed on 7/9/2018, 2:22:37 PM
Parent: 5bbde5f671cc6a6ada171d0696db06cc13652771

Files changed

index.jschanged
package-lock.jsonchanged
package.jsonchanged
server-process.jschanged
index.jsView
@@ -11,15 +11,22 @@
1111 var WindowState = require('electron-window-state')
1212 var Menu = electron.Menu
1313 var extend = require('xtend')
1414 var ssbKeys = require('ssb-keys')
15 +var program = require('commander')
1516
1617 var windows = {
1718 dialogs: new Set()
1819 }
1920 var ssbConfig = null
2021 var quitting = false
2122
23 +// parse program args
24 +program
25 + .option('-g, --use-global-ssb', 'Use a global instance of sbot (Patchwork starts its own instance by default)')
26 + .option('-p, --path <path>', 'Use a specific path to database files (default is $HOME/.ssb)')
27 + .parse(process.argv)
28 +
2229 /**
2330 * It's not possible to run two instances of patchwork as it would create two
2431 * scuttlebot instances that conflict on the same port. Before opening patchwork,
2532 * we check if it's already running and if it is we focus the existing window
@@ -40,12 +47,22 @@
4047 }
4148
4249 quitIfAlreadyRunning()
4350
51 +// pass program arguments into ssb-config
52 +var config = {
53 + server: !program.useGlobalSsb
54 +}
55 +if (program.path) {
56 + config.path = Path.resolve(program.path)
57 + // currently git-ssb-web doesn't accept config options
58 + // so a different path than the default would cause it to blow up
59 + // so passing in a flag to server-process to skip launching it
60 + config.customPath = true
61 +}
62 +
4463 electron.app.on('ready', () => {
45- setupContext('ssb', {
46- server: !(process.argv.includes('-g') || process.argv.includes('--use-global-ssb'))
47- }, () => {
64 + setupContext('ssb', config, () => {
4865 var browserWindow = openMainWindow()
4966 var menu = defaultMenu(electron.app, electron.shell)
5067
5168 menu.splice(4, 0, {
package-lock.jsonView
The diff is too large to show. Use a local git client to view these changes.
Old file size: 283508 bytes
New file size: 283507 bytes
package.jsonView
@@ -16,8 +16,9 @@
1616 "license": "AGPL-3.0",
1717 "dependencies": {
1818 "app-root-path": "^2.0.1",
1919 "bulk-require": "^1.0.1",
20 + "commander": "^2.16.0",
2021 "compare-version": "^0.1.2",
2122 "cross-script": "^1.0.5",
2223 "deep-equal": "^1.0.1",
2324 "depject": "^4.1.1",
server-process.jsView
@@ -32,15 +32,18 @@
3232 ssbConfig.manifest = context.sbot.getManifest()
3333 fs.writeFileSync(Path.join(ssbConfig.path, 'manifest.json'), JSON.stringify(ssbConfig.manifest))
3434 electron.ipcRenderer.send('server-started', ssbConfig)
3535
36- // attempt to run git-ssb if it is installed and in path
37- var gitSsb = spawn('git-ssb', [ 'web' ], {
38- stdio: 'inherit'
39- })
40- gitSsb.on('error', () => {
41- console.log('git-ssb is not installed, or not available in path')
42- })
43- process.on('exit', () => {
44- gitSsb.kill()
45- })
36 + // check if we are using a custom ssb path (which would break git-ssb-web)
37 + if (!ssbConfig.customPath) {
38 + // attempt to run git-ssb if it is installed and in path
39 + var gitSsb = spawn('git-ssb', [ 'web' ], {
40 + stdio: 'inherit'
41 + })
42 + gitSsb.on('error', () => {
43 + console.log('git-ssb is not installed, or not available in path')
44 + })
45 + process.on('exit', () => {
46 + gitSsb.kill()
47 + })
48 + }
4649 }

Built with git-ssb-web