Skip to content

Commit 7693331

Browse files
committed
Merge pull request #137 from elixir-lang/refine-rake-task
update rake tasks
2 parents ac74b39 + eacd74f commit 7693331

File tree

1 file changed

+76
-2
lines changed

1 file changed

+76
-2
lines changed

Rakefile

Lines changed: 76 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1+
EMACS = "emacs"
2+
CASK = "cask"
3+
4+
task default: %w[test]
5+
16
desc "Create a new release."
27
task 'release' do
38
current_version = run('git tag').split(/\n/).last.strip[1..-1]
4-
print "What version do you want to release? (current: #{current_version}): "
5-
version = STDIN.gets.strip
9+
version = ask("What version do you want to release? (current: #{current_version}): ")
610
version_tag = "v%s" % version
711

812
if run('git tag').split(/\n/).include?(version_tag)
@@ -16,6 +20,30 @@ task 'release' do
1620
git_changes(version, version_tag)
1721
end
1822

23+
desc "Installed Emacs information"
24+
task 'info' do
25+
process_info "Install Emacs information"
26+
say ""
27+
say "PATH: ", :green, false
28+
system "which #{EMACS}"
29+
say "VERSION: ", :green, false
30+
system "#{CASK} exec #{EMACS} --version | head -1"
31+
end
32+
33+
desc "Run the test suite"
34+
task "test" do
35+
process_info "Install package dependencies"
36+
say ""
37+
say "#{indent(3)}Command: ", :yellow, false
38+
sh "cask install"
39+
say ""
40+
41+
process_info "Run test suite"
42+
say ""
43+
system "#{CASK} exec ert-runner"
44+
say ""
45+
end
46+
1947
def git_changes(version, version_tag)
2048
run "git commit -a -m \"prepare #{version}\""
2149
run "git tag -a -m \"Version #{version}\" #{version_tag}"
@@ -27,6 +55,52 @@ def update_version(content, from, to)
2755
content = content.gsub("Version: #{from}", "Version: #{to}")
2856
end
2957

58+
def ansi
59+
{
60+
green: "\e[32m",
61+
red: "\e[31m",
62+
white: "\e[37m",
63+
bold: "\e[1m",
64+
on_green: "\e[42m",
65+
ending: "\e[0m"
66+
}
67+
end
68+
3069
def run(command)
3170
`#{command}`
3271
end
72+
73+
def say(message, type=:white, newline=true)
74+
message = "#{ansi[type]}#{message}#{ansi[:ending]}"
75+
if newline
76+
puts message
77+
else
78+
print message
79+
end
80+
end
81+
82+
def process_info(message)
83+
puts "#{ansi[:on_green]}#{ansi[:red]}#{message}#{ansi[:ending]}#{ansi[:ending]}"
84+
end
85+
86+
def info(message)
87+
puts "#{ansi[:green]}#{ansi[:bold]}#{message}#{ansi[:ending]}#{ansi[:ending]}"
88+
end
89+
90+
def ask(question, type=:white)
91+
say(question, type, false)
92+
answer = STDIN.gets.chomp
93+
if answer == "" || answer.nil?
94+
return nil
95+
else
96+
return answer
97+
end
98+
end
99+
100+
def indent(count)
101+
" " * count
102+
end
103+
104+
def colorize(string, color)
105+
"#{ansi[color]}#{string}#{ansi[:ending]}"
106+
end

0 commit comments

Comments
 (0)