Skip to content

Commit

Permalink
potentially closes #95 (#96)
Browse files Browse the repository at this point in the history
  • Loading branch information
tlienart authored Feb 26, 2020
1 parent 6f5f363 commit 6a73ed0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "LiveServer"
uuid = "16fef848-5104-11e9-1b77-fb7a48bbb589"
authors = ["Jonas Asprion <[email protected]", "Thibaut Lienart <[email protected]>"]
version = "0.3.5"
version = "0.3.6"

This comment has been minimized.

Copy link
@tlienart

tlienart Feb 26, 2020

Author Collaborator

[deps]
Crayons = "a8cc5b0e-0ffa-5ad4-8c14-923d3ee1735f"
Expand Down
7 changes: 5 additions & 2 deletions src/file_watching.jl
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,12 @@ function file_watcher_task!(fw::FileWatcher)
fw.callback(wf.path)
elseif state == -1
# the file does not exist, eventually delete it from list of watched files
VERBOSE[] && @info("[FileWatcher]: file '$(wf.path)' does not exist " *
" (anymore); removing it from list of watched files.")
push!(deleted_files, i)
if VERBOSE[]
@info "[FileWatcher]: file '$(wf.path)' does not " *
"exist (anymore); removing it from list of " *
" watched files."
end
end
end
# remove deleted files from list of watched files
Expand Down
17 changes: 12 additions & 5 deletions src/server.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,20 @@ end
"""
file_changed_callback(f_path::AbstractString)
Function reacting to the change of the file at `f_path`. Is set as callback for the file watcher.
Function reacting to the change of the file at `f_path`. Is set as callback for
the file watcher.
"""
function file_changed_callback(f_path::AbstractString)
VERBOSE[] && println("ℹ [LiveUpdater]: Reacting to change in file '$f_path'...")
if VERBOSE[]
println("ℹ [LiveUpdater]: Reacting to change in file '$f_path'...")
end
if endswith(f_path, ".html")
# if html file, update viewers of this file only
update_and_close_viewers!(WS_VIEWERS[f_path])
# check the viewer still exists otherwise may error
# see issue https://github.com/asprionj/LiveServer.jl/issues/95
if haskey(WS_VIEWERS, f_path)
update_and_close_viewers!(WS_VIEWERS[f_path])
end
else
# otherwise (e.g. modification to a CSS file), update all viewers
foreach(update_and_close_viewers!, values(WS_VIEWERS))
Expand All @@ -40,8 +47,8 @@ end
"""
get_fs_path(req_path::AbstractString)
Return the filesystem path corresponding to a requested path, or an empty String if the file
was not found.
Return the filesystem path corresponding to a requested path, or an empty
String if the file was not found.
"""
function get_fs_path(req_path::AbstractString)::String
# first element after the split is **always** "/"
Expand Down

1 comment on commit 6a73ed0

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

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

Registration pull request created: JuliaRegistries/General/10142

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if Julia TagBot is installed, or can be done manually through the github interface, or via:

git tag -a v0.3.6 -m "<description of version>" 6a73ed047fde5e78af961bc5395f4c6f93a2e6a2
git push origin v0.3.6

Please sign in to comment.