From 625bf6d2d43904df99473c5bfb6ad9df945af080 Mon Sep 17 00:00:00 2001 From: Chris Knepper Date: Thu, 21 Jun 2018 21:46:13 -0400 Subject: [PATCH] -Add update mechanism via electron-updater -Add environment constants -Don't pop open dev tools in about window if we're in prod build --- src/background.js | 2 ++ src/constants/index.js | 27 ++++++++++++++++++++------- src/menu/items/about.js | 3 ++- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/background.js b/src/background.js index 00517e88..6c773a43 100644 --- a/src/background.js +++ b/src/background.js @@ -6,6 +6,7 @@ import path from "path"; import url from "url"; import { app, Menu } from "electron"; +import { autoUpdater } from 'electron-updater'; import { appMenuTemplate } from './menu/app_menu_template'; import { devMenuTemplate } from "./menu/dev_menu_template"; import { editMenuTemplate } from "./menu/edit_menu_template"; @@ -35,6 +36,7 @@ if (env.name !== "production") { app.on("ready", () => { setApplicationMenu(); + autoUpdater.checkForUpdatesAndNotify(); const mainWindow = createWindow("main", { width: 1100, diff --git a/src/constants/index.js b/src/constants/index.js index 599fa79c..88c49702 100644 --- a/src/constants/index.js +++ b/src/constants/index.js @@ -1,13 +1,26 @@ +import env from 'env'; + const osMap = { - win32: "Windows", - darwin: "macOS", - linux: "Linux" + win32: 'Windows', + darwin: 'macOS', + linux: 'Linux' }; +// Operating system const osName = process.platform; const osNameFriendly = osMap[osName]; -const IS_WINDOWS = osName === 'win32'; -const IS_MAC = osName === 'darwin'; -const IS_LINUX = osName === 'linux'; +const IS_WINDOWS = (osName === 'win32'); +const IS_MAC = (osName === 'darwin'); +const IS_LINUX = (osName === 'linux'); + +// Environment +const IS_DEV = (env.name === 'development'); -export { osName, osNameFriendly, IS_WINDOWS, IS_MAC, IS_LINUX }; +export { + osName, + osNameFriendly, + IS_WINDOWS, + IS_MAC, + IS_LINUX, + IS_DEV +}; diff --git a/src/menu/items/about.js b/src/menu/items/about.js index 3432869d..ca5e3bb4 100644 --- a/src/menu/items/about.js +++ b/src/menu/items/about.js @@ -1,4 +1,5 @@ import appIcon from '../../../resources/icons/512x512.png'; +import { IS_DEV } from '../../constants'; import openAboutWindow from 'about-window'; export const aboutMenu = () => { @@ -6,6 +7,6 @@ export const aboutMenu = () => { icon_path: appIcon, copyright: 'Copyright © 2018 Chris Knepper, All rights reserved.', product_name: 'Android Messages Desktop', - open_devtools: true + open_devtools: IS_DEV }); };