Skip to content

Commit

Permalink
[Desktop] Use electron-is-dev instead of NODE_ENV
Browse files Browse the repository at this point in the history
Fix problem on Windows without bash shell
  • Loading branch information
brunolemos committed Dec 28, 2018
1 parent f2a8274 commit 2785c78
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
"main": "dist/index.js",
"scripts": {
"build": "yarn clean && yarn compile && pushd ../web && yarn build && popd && yarn build:electron",
"build:electron": "NODE_ENV=production electron-builder -mw",
"build:electron": "electron-builder -mw",
"compile": "tsc -b",
"clean": "rm -rf build && rm -rf dist",
"format": "prettier --write '{.,src/**}/*.{js,jsx,ts,tsx}'",
"lint": "tslint -p .",
"predeploy": "yarn run build",
"start": "NODE_ENV=development nodemon --watch dist/*.js --watch assets --exec \"electron .\"",
"start": "nodemon --watch dist/*.js --watch assets --exec \"electron .\"",
"test": "echo \"Error: no test specified\" && exit 1"
},
"build": {
Expand Down
2 changes: 1 addition & 1 deletion packages/desktop/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
} from 'electron'
import path from 'path'

const __DEV__ = process.env.NODE_ENV === 'development'
import { __DEV__ } from './libs/electron-is-dev'

let mainWindow: Electron.BrowserWindow
let tray: Electron.Tray | null = null
Expand Down
12 changes: 12 additions & 0 deletions packages/desktop/src/libs/electron-is-dev/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Source: https://github.com/sindresorhus/electron-is-dev

import electron from 'electron'

const app = electron.app || electron.remote.app

const isEnvSet = 'ELECTRON_IS_DEV' in process.env
const getFromEnv =
!!process.env.ELECTRON_IS_DEV &&
parseInt(process.env.ELECTRON_IS_DEV, 10) === 1

export const __DEV__ = isEnvSet ? getFromEnv : !app.isPackaged

0 comments on commit 2785c78

Please sign in to comment.