Skip to content

Commit 5ea0f8c

Browse files
authored
Adding the compile time to the watcher for development (#1855)
* Adding the compile time to the watcher for development. Fixes #1851 * Formatting the compiled time for a more human readable format
1 parent c493598 commit 5ea0f8c

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

tasks/watch.cr

+12-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
require "lucky_task"
2-
require "option_parser"
32
require "colorize"
43
require "yaml"
54
require "http"
65
require "../src/lucky/server_settings"
6+
require "../src/lucky/page_helpers/time_helpers"
77

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

143143
class ProcessRunner
144144
include LuckyTask::TextHelpers
145+
include Lucky::TimeHelpers
145146

146147
getter build_processes = [] of Process
147148
getter app_processes = [] of Process
@@ -152,8 +153,10 @@ module LuckySentry
152153

153154
@app_built : Bool = false
154155
@successful_compilations : Int32 = 0
156+
@build_started : Time::Span
155157

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

159162
private def build_app_processes_and_start
@@ -262,7 +265,14 @@ module LuckySentry
262265
if build_success
263266
self.app_built = true
264267
create_app_processes
265-
puts "#{" Done ".colorize.on_cyan.black} compiling"
268+
269+
elapsed_time = Time.monotonic - @build_started
270+
message = String.build do |io|
271+
io << " DONE ".colorize.on_cyan.black
272+
io << " Compiled successfully in #{distance_of_time_in_words(elapsed_time)}".colorize.cyan
273+
end
274+
275+
puts message
266276
elsif !app_built
267277
print_error_message
268278
end

0 commit comments

Comments
 (0)