Class: ViteRuby::Runner

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/vite_ruby/runner.rb

Overview

Public: Executes Vite commands, providing conveniences for debugging.

Instance Method Summary collapse

Constructor Details

#initialize(vite_ruby) ⇒ Runner

Returns a new instance of Runner.



5
6
7
# File 'lib/vite_ruby/runner.rb', line 5

def initialize(vite_ruby)
  @vite_ruby = vite_ruby
end

Instance Method Details

#run(argv, exec: false) ⇒ Object

Public: Executes Vite with the specified arguments.



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/vite_ruby/runner.rb', line 10

def run(argv, exec: false)
  config.within_root {
    cmd = command_for(argv)
    return Kernel.exec(*cmd) if exec

    log_or_noop = ->(line) { logger.info('vite') { line } } unless config.hide_build_console_output
    ViteRuby::IO.capture(*cmd, chdir: config.root, with_output: log_or_noop)
  }
rescue Errno::ENOENT => error
  raise ViteRuby::MissingExecutableError, error
end