-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
It would be useful if a proc could be passed as the second argument of the watch method to allow custom commands based on the name of the changed file. For example:
custom_command = ->(file : String) : String? do
# ... build a command based on the changed file, return the string
end
Watch.watch "./**/*.cr", custom_commandAn example usage could be running the respective spec file for any file in the src/ dir:
# runs matching spec for any file in /src
run_spec = ->(file : String) : String? do
spec = file
.sub(/^\.\/src\//, "./spec/")
.sub(/(_spec|_flow)?\.cr$/, "_spec.cr")
if File.exists?(spec)
puts %(> running "#{spec}")
"crystal spec #{spec}"
else
puts %(> matching spec "#{spec}" does not exist)
end
end
Watch.watch "./**/*.cr", run_specReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels