Skip to content

Commit

Permalink
Added error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
firejune committed Nov 15, 2017
1 parent 22c7866 commit 4b59c11
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions api.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,23 @@ const electron = require('electron')
// devtools-extension install
exports.install = () => {
if (!electron.remote) {
throw new Error('React DevTools cannot be installed from within the main process.')
throw new Error('React DevTools can only be installed from an renderer process.')
}

const extensions = electron.remote.BrowserWindow.getDevToolsExtensions()
if (extensions && extensions['React Developer Tools']) return


const path = electron.remote.BrowserWindow.addDevToolsExtension(__dirname)
console.log(`Installing React DevTools from ${__dirname}`)

return electron.remote.BrowserWindow.addDevToolsExtension(__dirname)
return path
}

// devtools-extension uninstall
exports.uninstall = () => {
if (!electron.remote) {
throw new Error('React DevTools can only be uninstalled from an renderer process.')
}
return electron.remote.BrowserWindow.removeDevToolsExtension('React Developer Tools')
}

0 comments on commit 4b59c11

Please sign in to comment.