Skip to content

Commit

Permalink
added flag to disable/enable dev tool
Browse files Browse the repository at this point in the history
  • Loading branch information
dtn9197 committed Jun 16, 2020
1 parent d288987 commit 0e57545
Showing 1 changed file with 30 additions and 2 deletions.
32 changes: 30 additions & 2 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,45 @@
const {app, BrowserWindow} = require("electron");
const {app, BrowserWindow, Menu} = require("electron");
const path = require("path");

//flag for production or dev environment
process.env.NODE_ENV = "development";

//create menu with chrome devtool
var mainMenuTemplate = [
{
label: 'Developer Tools',
click(item, focusedWindow) {
focusedWindow.toggleDevTools();
}

}
];



function createWindow() {

var mainWindow = new BrowserWindow();

//add dev tool option to menu
const mainMenu = Menu.buildFromTemplate(mainMenuTemplate);
Menu.setApplicationMenu(mainMenu);


mainWindow.loadFile(path.join(__dirname, "mainWindow.html"));
if(process.env.NODE_ENV === "production")
mainWindow.removeMenu();

//Quit app when closed
mainWindow.on("closed", function() {
app.quit();
})



}

app.on("ready", function() {
createWindow();
})
})

0 comments on commit 0e57545

Please sign in to comment.