diff --git a/electron/constants.js b/electron/constants.js index 6de0c8878..2d4da10fb 100644 --- a/electron/constants.js +++ b/electron/constants.js @@ -4,6 +4,8 @@ const ERROR_ADDRESS_IN_USE = 'EADDRINUSE'; const isWindows = process.platform === 'win32'; const isMac = process.platform === 'darwin'; const isLinux = process.platform === 'linux'; +const isProd = process.env.NODE_ENV === 'production'; +const isDev = !isProd; module.exports = { PORT_RANGE, @@ -11,4 +13,6 @@ module.exports = { isWindows, isMac, isLinux, + isProd, + isDev, }; diff --git a/electron/constants/paths.js b/electron/constants/paths.js index 32c7325cc..967ea7131 100644 --- a/electron/constants/paths.js +++ b/electron/constants/paths.js @@ -1,11 +1,11 @@ const os = require('os'); const path = require('path'); const fs = require('fs'); +const { isProd } = require('../constants'); -const dotOperateDirectory = - process.env.NODE_ENV === 'production' - ? path.join(os.homedir(), '.operate') - : '.operate'; +const dotOperateDirectory = isProd + ? path.join(os.homedir(), '.operate') + : '.operate'; // Create operate directory if it doesn't exist if (!fs.existsSync(dotOperateDirectory)) { diff --git a/electron/main.js b/electron/main.js index c7edf4263..923a98a4e 100644 --- a/electron/main.js +++ b/electron/main.js @@ -28,6 +28,7 @@ const { PORT_RANGE, isWindows, isMac } = require('./constants'); const { macUpdater } = require('./update'); const { setupStoreIpc } = require('./store'); const { logger } = require('./logger'); +const { isDev } = require('./constants'); // Configure environment variables dotenv.config(); @@ -37,7 +38,6 @@ const singleInstanceLock = app.requestSingleInstanceLock(); if (!singleInstanceLock) app.quit(); const platform = os.platform(); -const isDev = process.env.NODE_ENV === 'development'; const binaryPaths = { darwin: {