forked from electron-userland/devtron
-
Notifications
You must be signed in to change notification settings - Fork 0
/
api.js
31 lines (28 loc) · 1.23 KB
/
api.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
const electron = require('electron')
exports.install = () => {
if (process.type === 'renderer') {
console.log(`Installing Devtron from ${__dirname}`)
if (electron.remote.BrowserWindow.getDevToolsExtensions &&
electron.remote.BrowserWindow.getDevToolsExtensions().devtron) return true
return electron.remote.BrowserWindow.addDevToolsExtension(__dirname)
} else if (process.type === 'browser') {
console.log(`Installing Devtron from ${__dirname}`)
if (electron.BrowserWindow.getDevToolsExtensions &&
electron.BrowserWindow.getDevToolsExtensions().devtron) return true
return electron.BrowserWindow.addDevToolsExtension(__dirname)
} else {
throw new Error('Devtron can only be installed from an Electron process.')
}
}
exports.uninstall = () => {
if (process.type === 'renderer') {
console.log(`Uninstalling Devtron from ${__dirname}`)
return electron.remote.BrowserWindow.removeDevToolsExtension('devtron')
} else if (process.type === 'browser') {
console.log(`Uninstalling Devtron from ${__dirname}`)
return electron.BrowserWindow.removeDevToolsExtension('devtron')
} else {
throw new Error('Devtron can only be uninstalled from an Electron process.')
}
}
exports.path = __dirname