Skip to content

Commit

Permalink
Fix ELECTRON_ENVIRONMENT.js
Browse files Browse the repository at this point in the history
This script is now getting bundled into `main.js` before `package.json` is modified by electron-builder
But the build process sets the `process.env.ELECTRON_ENV` so it's not a problem to just remove these lines

Note: updated return docs - the returned values are the lowercase names and not ['PROD', 'STG', 'DEV']
  • Loading branch information
kidroca committed Feb 15, 2022
1 parent 8a09b0e commit b8cf68e
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions desktop/ELECTRON_ENVIRONMENT.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,10 @@
// This variable is injected into package.json by electron-builder via the extraMetadata field (specified in electronBuilder.config.js)
// It will be `PROD` on production, `STG` on staging, and `undefined` on dev (because dev doesn't use electron-builder)
const {electronEnvironment} = require('../package.json');
const ENVIRONMENT = require('../src/CONST/ENVIRONMENT');

/**
* @returns {String} – One of ['PROD', 'STG', 'DEV']
* @returns {'development'|'staging'|'production'}
*/
function getEnvironment() {
// If we are on dev, then the ELECTRON_ENVIRONMENT environment variable will be present (set in package.json desktop script `npm run desktop`)
if (process.env.ELECTRON_ENV === ENVIRONMENT.DEV) {
return ENVIRONMENT.DEV;
}

// Otherwise, use the environment injected into package.json by electron-builder
return electronEnvironment;
return process.env.ELECTRON_ENV;
}

function isDev() {
Expand Down

0 comments on commit b8cf68e

Please sign in to comment.