-
-
Notifications
You must be signed in to change notification settings - Fork 530
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(plugin-local-electron): Make the plugin compatible on Windows, and can live with other plugins #3259
base: main
Are you sure you want to change the base?
fix(plugin-local-electron): Make the plugin compatible on Windows, and can live with other plugins #3259
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -20,30 +20,20 @@ describe('LocalElectronPlugin', () => { | |||||||
it('should set ELECTRON_OVERRIDE_DIST_PATH when enabled', async () => { | ||||||||
expect(process.env.ELECTRON_OVERRIDE_DIST_PATH).to.equal(undefined); | ||||||||
const p = new LocalElectronPlugin({ electronPath: 'test/foo' }); | ||||||||
await p.startLogic(); | ||||||||
p.init(); | ||||||||
expect(process.env.ELECTRON_OVERRIDE_DIST_PATH).to.equal('test/foo'); | ||||||||
}); | ||||||||
|
||||||||
it('should not set ELECTRON_OVERRIDE_DIST_PATH when disabled', async () => { | ||||||||
expect(process.env.ELECTRON_OVERRIDE_DIST_PATH).to.equal(undefined); | ||||||||
const p = new LocalElectronPlugin({ enabled: false, electronPath: 'test/foo' }); | ||||||||
await p.startLogic(); | ||||||||
p.init(); | ||||||||
expect(process.env.ELECTRON_OVERRIDE_DIST_PATH).to.equal(undefined); | ||||||||
}); | ||||||||
|
||||||||
it("should throw an error if platforms don't match", async () => { | ||||||||
const p = new LocalElectronPlugin({ electronPath: 'test/bar', electronPlatform: 'wut' }); | ||||||||
await expect(p.startLogic()).to.eventually.be.rejectedWith( | ||||||||
`Can not use local Electron version, required platform "${process.platform}" but local platform is "wut"` | ||||||||
); | ||||||||
}); | ||||||||
|
||||||||
it('should always return false', async () => { | ||||||||
let p = new LocalElectronPlugin({ electronPath: 'test/bar' }); | ||||||||
expect(await p.startLogic()).to.equal(false); | ||||||||
|
||||||||
p = new LocalElectronPlugin({ enabled: false, electronPath: 'test/bar' }); | ||||||||
expect(await p.startLogic()).to.equal(false); | ||||||||
expect(p.init).to.throw(`Can not use local Electron version, required platform "${process.platform}" but local platform is "wut"`); | ||||||||
}); | ||||||||
}); | ||||||||
|
||||||||
|
@@ -53,7 +43,11 @@ describe('LocalElectronPlugin', () => { | |||||||
beforeEach(() => { | ||||||||
p = new LocalElectronPlugin({ electronPath: 'test/foo' }); | ||||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||||||||
p.init('', {} as any); | ||||||||
p.init(); | ||||||||
}); | ||||||||
|
||||||||
after(() => { | ||||||||
delete process.env.ELECTRON_OVERRIDE_DIST_PATH; | ||||||||
Comment on lines
+49
to
+50
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is not, because the delete you referenced is in the other scope. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, my bad for not catching that! Would it be better to use |
||||||||
}); | ||||||||
|
||||||||
describe('with afterExtract hook', () => { | ||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes here seem unnecessary because
init
andstartLogic
are responsible for different things. init is responsible for initializing the template, whilestartLogic
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This plugin merely just set the environment variable, and using
startLogic
will prevent it from using with other plugins likevite
.This could go to constructor if
init
is not a right place to go.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not very familiar with this piece of code. Perhaps other people might have some suggestions.
@caoxiemeihao @electron/forgers PLAT