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

entr enhancements [feature suggestions] #305

Closed
essenciary opened this issue May 9, 2019 · 6 comments
Closed

entr enhancements [feature suggestions] #305

essenciary opened this issue May 9, 2019 · 6 comments
Labels
wishlist Feature requests

Comments

@essenciary
Copy link

essenciary commented May 9, 2019

Here are a few suggested features which would make entr more powerful:

1 - pass the matched file as an argument to the callback function.
Something in the line of:

entr([...]) do file 
...
end

This would allow for more granular logic.

2 - allow passing folders, not just files. There's rarely a need to watch individual files, it's more like "all the files in this folder" (ideally recursively).

3 - it really shouldn't be blocking, but I assume that can be easily addressed with @spawn, @fetch, etc.


My use case would be something like this:

if config.AUTO_RELOAD 
  @spawn entr(
    filter(Revise.watched_files) do file_path
      startswith(file_path, Genie.APP_PATH)
    end
  ) do  
    websockets.reload_page()
  end
end

If you think they'd be useful I can make a PR.

@timholy
Copy link
Owner

timholy commented May 23, 2019

Yes, please make a PR. Note #308.

@essenciary
Copy link
Author

@timholy Thanks, will do!

@timholy timholy added the wishlist Feature requests label Aug 31, 2019
@tkluck
Copy link
Contributor

tkluck commented Mar 25, 2020

As for (3) you might be interested in #443 .

@c42f
Copy link
Collaborator

c42f commented Nov 19, 2020

With #488 is merged, most of this is addressed.

(1) is mostly addressed because functions f passed to add_callback(f, [files]) are only triggered for the specific files listed.
(3) is fixed directly because add_callback isn't blocking.

(2) is not yet addressed, I think.

@ffevotte
Copy link
Collaborator

ffevotte commented Nov 19, 2020

I think (2) should be addressed as well, especially thanks to

Revise.jl/src/pkgs.jl

Lines 313 to 317 in 397db6d

if isdir(fullpath)
# Detected a modification in a directory that we're watching in
# itself (not as a container for watched files)
push!(latestfiles, file=>id)
continue

Example:

julia> mkdir("foo")
"foo"

julia> using Revise

julia> t = @async Revise.entr(["foo"], postpone=true) do
         println("update")
       end
Task (runnable) @0x00007feed259b820

# Watching a directory translates to watching file "" within directory itself ("/tmp/foo")
julia> Revise.watched_files
Dict{String,Revise.WatchList} with 1 entry:
  "/tmp/foo" => WatchList(1.60578e9, Dict{String,Base.PkgId}(""=> [top-level]))

# File creation
julia> touch("foo/bar"); sleep(1)
update

# File creation, again
julia> touch("foo/baz"); sleep(1)
update

# File modification
julia> touch("foo/bar"); sleep(1)
update

# File deletion
julia> rm("foo/baz"); sleep(1)
update

(I seem to recall that watching directories can behave differently on some systems...)

@timholy
Copy link
Owner

timholy commented Nov 19, 2020

Let's close this. Thanks for all who have contributed to entr!

@timholy timholy closed this as completed Nov 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wishlist Feature requests
Projects
None yet
Development

No branches or pull requests

5 participants