Skip to content
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

make mainjs relocatable #130

Merged
merged 10 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
/deps
!/deps/build.jl
.vscode
Manifest.toml
18 changes: 10 additions & 8 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,24 @@ uuid = "a1bb12fb-d4d1-54b4-b10a-ee7951ef7ad3"
version = "5.0.1-DEV"

[deps]
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
FilePaths = "8fc22ac5-c921-52a6-82fd-178b2807b824"
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
URIs = "5c2747f8-b7ea-4ff2-ba2e-563bfd36b1d4"
RelocatableFolders = "05181044-ff0b-4ac5-8273-598c1e38db00"
Sockets = "6462fe0b-24de-5631-8697-dd941f90decc"
URIs = "5c2747f8-b7ea-4ff2-ba2e-563bfd36b1d4"
UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
FilePaths = "8fc22ac5-c921-52a6-82fd-178b2807b824"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[compat]
FilePaths = "0.8.1"
JSON = "0.19, 0.20, 0.21"
julia = "1.6"
RelocatableFolders = "1"
URIs = "1.3"
FilePaths = "0.8.1"
julia = "1.6"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test"]
9 changes: 7 additions & 2 deletions src/Electron.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module Electron

using JSON, URIs, Sockets, Base64, Pkg.Artifacts, FilePaths, UUIDs
using RelocatableFolders

export Application, Window, URI, windows, applications, msgchannel, toggle_devtools, load, ElectronAPI

Expand Down Expand Up @@ -123,14 +124,18 @@ function get_electron_binary_cmd()
end
end

const MAIN_JS = @path joinpath(@__DIR__, "main.js")

"""
function Application()

Start a new Electron application. This will start a new process
for that Electron app and return an instance of `Application` that
can be used in the construction of Electron windows.
"""
function Application(;mainjs=joinpath(@__DIR__, "main.js"), additional_electron_args = String[])
function Application(; mainjs=normpath(String(MAIN_JS)), additional_electron_args=String[])
@assert isfile(mainjs)
read(mainjs) # This seems to be required to not hang windows CI?!
electron_path = get_electron_binary_cmd()

id = replace(string(uuid1()), "-"=>"")
Expand All @@ -152,7 +157,7 @@ function Application(;mainjs=joinpath(@__DIR__, "main.js"), additional_electron_
secure_cookie_encoded,
additional_electron_args...
])

new_env = copy(ENV)
if haskey(new_env, "ELECTRON_RUN_AS_NODE")
delete!(new_env, "ELECTRON_RUN_AS_NODE")
Expand Down
Loading