Module: SimpleCov::CLI::Run

Extended by:
Run
Included in:
Run
Defined in:
lib/simplecov/cli/run.rb

Constant Summary collapse

AUTOSTART =
File.expand_path("../autostart", __dir__.to_s)

Instance Method Summary collapse

Instance Method Details

#exec_command(env, cmd) ⇒ Object



23
24
25
# File 'lib/simplecov/cli/run.rb', line 23

def exec_command(env, cmd)
  Kernel.exec(env, *cmd)
end

#rubyopt_envObject



27
28
29
30
31
32
# File 'lib/simplecov/cli/run.rb', line 27

def rubyopt_env
  existing = ENV["RUBYOPT"].to_s.strip
  injection = "-r#{AUTOSTART}"
  merged = existing.empty? ? injection : "#{existing} #{injection}"
  ENV.to_hash.merge("RUBYOPT" => merged)
end

#run(args, stderr:) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/simplecov/cli/run.rb', line 10

def run(args, stderr:, **)
  cmd = args.first.eql?("--") ? args.drop(1) : args
  if cmd.empty?
    stderr.puts("simplecov run: missing command")
    return 1
  end

  exec_command(rubyopt_env, cmd)
rescue Errno::ENOENT => e
  stderr.puts("simplecov run: #{e}")
  127
end