Class: Ruwi::Cli::Command::Dev

Inherits:
Base
  • Object
show all
Defined in:
lib/ruwi/cli/command/dev.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.descriptionObject



13
14
15
# File 'lib/ruwi/cli/command/dev.rb', line 13

def self.description
  "Start development server with file watching and auto-build"
end

Instance Method Details

#run(_argv) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/ruwi/cli/command/dev.rb', line 17

def run(_argv)
  log_info("Starting development server...")
  puts ""

  ensure_src_directory
  ensure_ruby_wasm

  # Initial build
  log_info("Performing initial build...")
  build
  log_success("✓ Initial build completed")
  puts ""

  # Start file watcher in a separate thread
  @build_lock = Mutex.new
  @build_queue = Queue.new
  @listener = nil
  @watcher_thread = nil

  @watcher_thread = Thread.new do
    start_file_watcher
  end

  # Register cleanup hook to ensure cleanup runs on exit
  @cleanup_done = false
  at_exit do
    cleanup unless @cleanup_done
  end

  # Start development server
  begin
    start_server
  ensure
    cleanup
  end
end