fix(plugin-local-electron): Make the plugin compatible on Windows, and can live with other plugins#3259
fix(plugin-local-electron): Make the plugin compatible on Windows, and can live with other plugins#3259reitowo wants to merge 4 commits intoelectron:mainfrom
Conversation
Make local-electron compatible with vite plugin
|
@caoxiemeihao Can I bother you review this? |
|
@VerteDinde Can you review this PR?😘 |
| init = (): void => { | ||
| if (this.enabled) { | ||
| this.checkPlatform(process.platform); | ||
| process.env.ELECTRON_OVERRIDE_DIST_PATH = this.config.electronPath; | ||
| } | ||
| }; | ||
|
|
There was a problem hiding this comment.
The changes here seem unnecessary because init and startLogic are responsible for different things. init is responsible for initializing the template, while startLogic is responsible for starting Electron. So I didn't quite understand the modifications here. Could you please explain in detail the necessity of these changes?
There was a problem hiding this comment.
This plugin merely just set the environment variable, and using startLogic will prevent it from using with other plugins like vite.
This could go to constructor if init is not a right place to go.
There was a problem hiding this comment.
I'm not very familiar with this piece of code. Perhaps other people might have some suggestions.
@caoxiemeihao @electron/forgers PLAT
| after(() => { | ||
| delete process.env.ELECTRON_OVERRIDE_DIST_PATH; |
There was a problem hiding this comment.
This is duplicated with the existing code. See:
forge/packages/plugin/local-electron/test/LocalElectronPlugin_spec.ts
Lines 16 to 18 in a62c2a1
There was a problem hiding this comment.
It is not, because the delete you referenced is in the other scope.
There was a problem hiding this comment.
Ah, my bad for not catching that! Would it be better to use afterEach?
|
@reitowo please can you resolve conflicts? |
|
#3720 should resolve the issues with conflicting startLogic |
|
@brianlyn thanks for pointing that out! |
Summarize your changes:
The
plugin-local-electroncurrently cannot work withplugin-vite(or any other plugin) because it claimsstartLogic, which is unnecessary because it just merely set theELECTRON_OVERRIDE_DIST_PATHenv var.This PR:
initfunction instead ofstartLogiclocateElectronExecutableto detect thisELECTRON_OVERRIDE_DIST_PATHenv var to make the project directly starts the binary in the wanted path. (Because on Windows this env variable makes no effect and still launch the binary undernode_modules...)