electron-builder package for windows in dev mode

半城伤御伤魂 提交于 2019-12-11 19:07:03

问题


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?


回答1:


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"




回答2:


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^""


来源:https://stackoverflow.com/questions/53072263/electron-builder-package-for-windows-in-dev-mode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!