electron-builder package for windows in dev mode

2019-08-28 22:23发布

I need to test my app on windows, but I am using a mac. It is very easy to package the app to run on windows, but I cannot package the app in dev-mode. I am using electron-is-dev to decide if I am running in dev or not. I need to run my tests on windows because I am testing a very specific windows hardware functionality. I don't want to comment my if(isDev){doSomething} just to run these test, and then uncomment it before I push the change. I was hoping there is some flag I can set in the electron-build cli, or maybe run electon . -windows?

2条回答
小情绪 Triste *
2楼-- · 2019-08-28 22:30

Parse the parameter by adding sample code below to your electron main.js

const args = process.argv.slice(1);
windows = args.some(val => val === '-windows');

It can still be parsed on electron executable app by running in cmd like "electronapp.exe -windows"

查看更多
一夜七次
3楼-- · 2019-08-28 22:35

The best way to do this so as to use the IsDev is to add the ELECTRON_IS_DEV environment variable to the app kinda like @carlokid suggested. I used: https://stackoverflow.com/a/34769146/3966009. This is the target I used for my app:

C:\Windows\System32\cmd.exe /c "SET ELECTRON_IS_DEV=1 && START ^"^" ^"C:\Program Files (x86)\My App\Fun Time.exe^""
查看更多
登录 后发表回答