WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit ba0706f

Browse files
committed
open inspector when running in dev mode
1 parent b9fe9ce commit ba0706f

File tree

4 files changed

+24
-1
lines changed

4 files changed

+24
-1
lines changed

cmd/run.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,18 @@ module.exports = (ipc) =>
246246
})
247247
})
248248

249+
// open the inspector when in devmode
250+
// (except if we're opening the pear://runtime app to avoid loop)
251+
const PEAR_RUNTIME_KEY = constants.ALIASES.runtime.toString('hex')
252+
253+
if (flags.dev && key !== PEAR_RUNTIME_KEY) {
254+
const inspectorKey = (await ipc.inspect()).toString('hex')
255+
daemon(constants.RUNTIME, [
256+
'run',
257+
`pear://${PEAR_RUNTIME_KEY}/dev?${inspectorKey}`
258+
])
259+
}
260+
249261
return new Promise((resolve) => global.Pear.teardown(resolve, Infinity))
250262
}
251263

examples/desktop/index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
import Runtime from 'pear-electron'
33
import Bridge from 'pear-bridge'
44
import updates from 'pear-updates'
5+
import bareInspector from 'bare-inspector'
6+
import { Inspector } from 'pear-inspect'
7+
58

69
updates((update) => {
710
console.log('Application update available:', update)
@@ -14,6 +17,10 @@ const runtime = new Runtime()
1417
const pipe = await runtime.start({ bridge })
1518
pipe.on('close', () => Pear.exit())
1619

20+
const inspector = new Inspector({ inspector: bareInspector })
21+
const inspectorKey = await inspector.enable() // Pass the public key to the Session
22+
console.log(`Add this key to Pear Runtime: ${inspectorKey.toString('hex')}`)
23+
1724
pipe.on('data', (data) => {
1825
const cmd = Buffer.from(data).toString()
1926
if (cmd === 'hello from ui') pipe.write('sweet bidirectionality')

examples/desktop/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,14 @@
1818
}
1919
},
2020
"devDependencies": {
21+
"bare-inspector": "^5.0.0",
2122
"brittle": "^3.0.0",
23+
"pear-inspect": "^1.2.5",
2224
"pear-interface": "^1.0.0"
2325
},
2426
"dependencies": {
2527
"pear-bridge": "^1.2.1",
26-
"pear-electron": "^1.7.20",
28+
"pear-electron": "^1.7.25",
2729
"pear-messages": "^1.0.3",
2830
"pear-pipe": "^1.0.1",
2931
"pear-updates": "^1.0.1"

package-lock.json

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)