/
retest
executable file
·47 lines (35 loc) · 955 Bytes
/
retest
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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
#!/usr/bin/env ruby
require 'retest'
$stdout.sync = true
options = Retest::Options.new(ARGV)
if options.help?
$stdout.puts options.help
return
end
repository = Retest::Repository.new(files: Retest::VersionControl.files)
command = Retest::Command.for_options(options)
runner = Retest::Runners.runner_for(command.to_s)
sounds = Retest::Sounds.for(options)
sounds.play(:start)
runner.add_observer(sounds)
program = Retest::Program.new(
repository: repository,
command: command,
runner: runner
)
if options.params[:diff]
program.diff(options.params[:diff])
return
end
# Main action
$stdout.puts "Launching Retest..."
Listen.to('.', only: options.extension, relative: true) do |modified, added, removed|
begin
program.run(modified, added, removed)
rescue => e
$stdout.puts "Something went wrong: #{e.message}"
end
end.start
$stdout.puts "Ready to refactor! You can make file changes now"
# not blocking
sleep