-
Notifications
You must be signed in to change notification settings - Fork 13
/
Rakefile
69 lines (55 loc) · 1.48 KB
/
Rakefile
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# frozen_string_literal: true
require 'bundler'
require 'bundler/setup'
require 'rake/testtask'
Rake::TestTask.new(:spec) do |t|
t.pattern = 'spec/**/*_spec.rb'
t.libs.push 'spec'
end
$LOAD_PATH.push File.expand_path('lib', __dir__)
require 'csso/version'
Bundler::GemHelper.install_tasks
desc 'test is the default'
task test: :spec
task default: :spec
file 'csso' do
puts 'Fetching csso repo...'
`git clone --single-branch --depth 1 --no-hardlinks https://github.com/css/csso.git`
Dir.chdir('csso') do
puts 'Now making web-version, just in case.'
`npm install && npm run build`
end
end
desc 'updates csso repo'
task update_csso_repo: :csso do
# ??
Dir.chdir('csso') do
puts 'Updating csso...'
`git reset --hard && git pull --rebase`
`npm install && npm run build`
end
end
directory 'vendor/csso'
lib_template = 'lib/csso/csso.js.erb'
file Csso::CSSO_JS_LIB => [
lib_template,
'csso',
'vendor/csso',
'csso/.git/HEAD',
'csso/.git/refs/heads/master'
] do
puts "Generating #{Csso::CSSO_JS_LIB}"
`erb #{lib_template} > #{Csso::CSSO_JS_LIB}`
end
desc 'Generate bundled csso from repo'
task generate_files: [:csso, Csso::CSSO_JS_LIB]
desc 'Clean generated files'
task :rm_generated do
puts "Removing #{Csso::CSSO_JS_LIB}"
`rm #{Csso::CSSO_JS_LIB}`
end
task regenerate: %i[rm_generated generate_files]
desc 'Update CSSO'
task update_csso: %i[rm_generated update_csso_repo generate_files]
desc 'alias for generate_files'
task build: :generate_files