-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathRakefile
More file actions
28 lines (25 loc) · 845 Bytes
/
Rakefile
File metadata and controls
28 lines (25 loc) · 845 Bytes
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
require 'open3'
RED = "\033[31m".freeze
GREEN = "\033[32m".freeze
RESET = "\033[0m".freeze
def run_command(cmd, silent: true, print_command: false, report_status: false)
puts "#{GREEN}Running #{cmd}#{RESET}" if print_command
output = ''
Open3.popen2e(cmd) do |_stdin, stdout_stderr, thread|
stdout_stderr.each do |line|
puts line unless silent
output += line
end
exitcode = thread.value.exitstatus
unless exitcode.zero?
err = "#{RED}Command failed! Command: #{cmd}, Exit code: #{exitcode}"
# Print details if we were running silent
err += "\nOutput:\n#{output}" if silent
err += RESET
abort err
end
puts "#{GREEN}Command finished with status #{exitcode}#{RESET}" if report_status
end
output.chomp
end
Dir.glob(File.join('tasks/**/*.rake')).each { |file| load file }