-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathRakefile
More file actions
46 lines (40 loc) · 1.49 KB
/
Rakefile
File metadata and controls
46 lines (40 loc) · 1.49 KB
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
require 'bundler'
require 'multi_json'
require 'open-uri'
Bundler::GemHelper.install_tasks
def say(line)
puts " \e[32m=>\e[0m #{line}"
end
def execute(banner, command)
say(banner + "...")
output = `#{command} 2>&1`
unless $?.success?
$stderr.puts(" \e[31mOops, something went wrong!\e[0m\n\n")
$stderr.puts(output)
exit(1)
end
output
end
desc 'Updates and releases the stylus-source gem'
task ship: :update do
current_version = File.read('VERSION')
execute 'commiting the VERSION file', "git add VERSION && git commit -m '#{current_version}'"
Rake::Task['release'].invoke
end
desc "Downloads stylus into './vendor' and checks the latest released tag"
task :update do
raw = open('http://registry.npmjs.org/stylus') { |io| io.binmode.read }
metadata = MultiJson.load(raw)
current_version = File.read('VERSION')
version = ENV['VERSION'] || metadata['dist-tags']['latest']
tarball = metadata['versions'][version]['dist']['tarball']
say "Updating stylus source from #{current_version} to #{version}"
execute 'cleaning up old files', 'rm -rf vendor'
execute "download stylus #{version}", "wget #{tarball} -O stylus.tgz"
execute "upacking stylus #{version}", 'tar -zxvf stylus.tgz'
execute 'cleaning up', 'rm -rf stylus.tgz package/.npmignore'
execute 'updating stylus dependencies', 'mv package vendor && cd vendor && npm install .'
say 'updating VERSION file'
File.open('VERSION', 'w') { |file| file.write(version) }
say 'done!'
end