Skip to content

Commit

Permalink
Adding the compile time to the watcher for development (#1855)
Browse files Browse the repository at this point in the history
* Adding the compile time to the watcher for development. Fixes #1851

* Formatting the compiled time for a more human readable format
  • Loading branch information
jwoertink authored Mar 30, 2024
1 parent c493598 commit 5ea0f8c
Showing 1 changed file with 12 additions and 2 deletions.
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

0 comments on commit 5ea0f8c

Please sign in to comment.