Skip to content
This repository has been archived by the owner on Feb 16, 2024. It is now read-only.

Allow custom electron path #311

Merged
merged 1 commit into from
Feb 22, 2021

Conversation

raboof
Copy link
Contributor

@raboof raboof commented Feb 19, 2021

This is useful on systems (like NixOS) where the Electron downloaded
by go-astilectron does not work out of the box, but it is possible to
install a working Electron separately.

Refs #309

@coveralls
Copy link

coveralls commented Feb 19, 2021

Coverage Status

Coverage decreased (-0.2%) to 79.41% when pulling 0b464bc on raboof:allow-custom-electron-path into 6aa7218 on asticode:master.

paths.go Outdated
@@ -64,7 +64,7 @@ func newPaths(os, arch string, o Options) (p *Paths, err error) {
p.electronDownloadSrc = ElectronDownloadSrc(os, arch, o.VersionElectron)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather

  • you put lines 63 --> 67 in a if o.CustomElectronPath == ""
  • and in this function, the else is directly p.appExecutable = o.CustomElectronPath,

Otherwise this won't work

paths.go Outdated
@@ -64,7 +64,7 @@ func newPaths(os, arch string, o Options) (p *Paths, err error) {
p.electronDownloadSrc = ElectronDownloadSrc(os, arch, o.VersionElectron)
p.electronDownloadDst = filepath.Join(p.vendorDirectory, fmt.Sprintf("electron-%s-%s-v%s.zip", os, arch, o.VersionElectron))
p.electronUnzipSrc = p.electronDownloadDst
p.initAppExecutable(os, o.AppName)
p.initAppExecutable(os, o.CustomElectronPath, o.AppName)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to inject o.CustomElectronPath anymore

paths.go Outdated
case "windows":
p.appExecutable = filepath.Join(p.electronDirectory, "electron.exe")
} else {
p.appExecutable = customElectronPath;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI there are no ; in GO

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol habits die hard ;)

provisioner.go Outdated
@@ -151,6 +151,8 @@ func (p *defaultProvisioner) provisionAstilectron(ctx context.Context, paths Pat

// provisionElectron provisions electron
func (p *defaultProvisioner) provisionElectron(ctx context.Context, paths Paths, s ProvisionStatus, appName, os, arch, versionElectron string) error {
if paths.ElectronUnzipSrc() == "" { return nil }
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With GO formatting, this needs new lines:

if paths.ElectronUnzipSrc() == "" {
    return nil
}

provisioner.go Outdated
@@ -151,6 +151,8 @@ func (p *defaultProvisioner) provisionAstilectron(ctx context.Context, paths Pat

// provisionElectron provisions electron
func (p *defaultProvisioner) provisionElectron(ctx context.Context, paths Paths, s ProvisionStatus, appName, os, arch, versionElectron string) error {
if paths.ElectronUnzipSrc() == "" { return nil }

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for that new line

@raboof raboof force-pushed the allow-custom-electron-path branch from 0b34d5c to 5484f63 Compare February 20, 2021 08:10
paths.go Outdated
@@ -144,7 +148,6 @@ func ElectronDownloadSrc(os, arch, versionElectron string) string {
return fmt.Sprintf("https://github.com/electron/electron/releases/download/v%s/electron-v%s-%s-%s.zip", versionElectron, versionElectron, o, a)
}

// initAppExecutable initializes the app executable path
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you keep this comment?

@raboof
Copy link
Contributor Author

raboof commented Feb 20, 2021 via email

@asticode
Copy link
Owner

no worries. I think initAppExecutable is fine for now.

Once you've made the change, can you test running the example in your NixOS and let me know whether this works properly?

@raboof
Copy link
Contributor Author

raboof commented Feb 20, 2021 via email

@raboof raboof force-pushed the allow-custom-electron-path branch from 5484f63 to 560b52e Compare February 21, 2021 09:28
example/main.go Outdated
@@ -14,8 +14,9 @@ func main() {

// Create astilectron
a, err := astilectron.New(l, astilectron.Options{
AppName: "Test",
BaseDirectoryPath: "example",
//CustomElectronPath: "/nix/store/srxbsf62sapfi2vginqshhicbqgzsnsx-electron-11.2.3/bin/electron",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you remove this comment?

@asticode
Copy link
Owner

OK great, just remove the last comment and I'll merge the PR

@raboof raboof force-pushed the allow-custom-electron-path branch from 560b52e to 38e9da9 Compare February 21, 2021 10:05
This is useful on systems (like NixOS) where the Electron downloaded
by go-astilectron does not work out of the box, but it is possible to
install a working Electron separately.
@raboof raboof force-pushed the allow-custom-electron-path branch from 38e9da9 to 0b464bc Compare February 21, 2021 10:44
@asticode asticode merged commit 7c3f023 into asticode:master Feb 22, 2021
@asticode
Copy link
Owner

Cheers

@raboof
Copy link
Contributor Author

raboof commented Feb 22, 2021

thanks for the detailed directions/feedback!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants