-
Notifications
You must be signed in to change notification settings - Fork 63
/
Copy pathapp.js
41 lines (35 loc) · 925 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/* eslint no-console: 0 */
'use strict'
const electron = require('electron')
const app = electron.app
const ipcMain = electron.ipcMain
const BrowserWindow = electron.BrowserWindow
const DaemonFactory = require('ipfsd-ctl')
const df = DaemonFactory.create()
app.on('ready', () => {
const win = new BrowserWindow({
title: 'loading'
})
win.loadURL(`file://${app.getAppPath()}/public/index.html`)
})
ipcMain.on('start', ({ sender }) => {
console.log('starting disposable IPFS')
sender.send('message', 'starting disposable IPFS')
df.spawn((err, ipfsd) => {
if (err) {
sender.send('error', err)
throw err
}
console.log('get id')
sender.send('message', 'get id')
ipfsd.api.id((err, id) => {
if (err) {
sender.send('error', err)
throw err
}
console.log('got id', id)
sender.send('id', JSON.stringify(id))
ipfsd.stop()
})
})
})