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

Adding the compile time to the watcher for development #1855

Merged
merged 3 commits into from
Mar 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 12 additions & 2 deletions tasks/watch.cr
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
require "lucky_task"
require "option_parser"
require "colorize"
require "yaml"
require "http"
require "../src/lucky/server_settings"
require "../src/lucky/page_helpers/time_helpers"

# Based on the sentry shard with some modifications to output and build process.
module LuckySentry
Expand Down Expand Up @@ -142,6 +142,7 @@ module LuckySentry

class ProcessRunner
include LuckyTask::TextHelpers
include Lucky::TimeHelpers

getter build_processes = [] of Process
getter app_processes = [] of Process
Expand All @@ -152,8 +153,10 @@ module LuckySentry

@app_built : Bool = false
@successful_compilations : Int32 = 0
@build_started : Time::Span

def initialize(@build_commands : Array(String), @run_commands : Array(String), @files : Array(String), @reload_browser : Bool, @watcher : Watcher?)
@build_started = Time.monotonic
end

private def build_app_processes_and_start
Expand Down Expand Up @@ -262,7 +265,14 @@ module LuckySentry
if build_success
self.app_built = true
create_app_processes
puts "#{" Done ".colorize.on_cyan.black} compiling"

elapsed_time = Time.monotonic - @build_started
message = String.build do |io|
io << " DONE ".colorize.on_cyan.black
io << " Compiled successfully in #{distance_of_time_in_words(elapsed_time)}".colorize.cyan
end

puts message
elsif !app_built
print_error_message
end
Expand Down