forked from mmistakes/minimal-mistakes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
145 lines (122 loc) · 3.86 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
require "bundler/gem_tasks"
require "jekyll"
require "listen"
def listen_ignore_paths(base, options)
[
/_config\.ya?ml/,
/_site/,
/\.jekyll-metadata/
]
end
def listen_handler(base, options)
site = Jekyll::Site.new(options)
Jekyll::Command.process_site(site)
proc do |modified, added, removed|
t = Time.now
c = modified + added + removed
n = c.length
relative_paths = c.map{ |p| Pathname.new(p).relative_path_from(base).to_s }
print Jekyll.logger.message("Regenerating:", "#{relative_paths.join(", ")} changed... ")
begin
Jekyll::Command.process_site(site)
puts "regenerated in #{Time.now - t} seconds."
rescue => e
puts "error:"
Jekyll.logger.warn "Error:", e.message
Jekyll.logger.warn "Error:", "Run jekyll build --trace for more information."
end
end
end
task :preview do
base = Pathname.new('.').expand_path
options = {
"source" => base.join('test').to_s,
"destination" => base.join('test/_site').to_s,
"force_polling" => false,
"serving" => true,
"theme" => "minimal-mistakes-jekyll"
}
options = Jekyll.configuration(options)
ENV["LISTEN_GEM_DEBUGGING"] = "1"
listener = Listen.to(
base.join("_data"),
base.join("_includes"),
base.join("_layouts"),
base.join("_sass"),
base.join("assets"),
options["source"],
:ignore => listen_ignore_paths(base, options),
:force_polling => options['force_polling'],
&(listen_handler(base, options))
)
begin
listener.start
Jekyll.logger.info "Auto-regeneration:", "enabled for '#{options["source"]}'"
unless options['serving']
trap("INT") do
listener.stop
puts " Halting auto-regeneration."
exit 0
end
loop { sleep 1000 }
end
rescue ThreadError
# You pressed Ctrl-C, oh my!
end
Jekyll::Commands::Serve.process(options)
end
##############
# Jekyll tasks
##############
# Usage: rake serve, rake serve:prod
task :serve => ["serve:dev"]
namespace :serve do
desc "Serve development Jekyll site locally"
task :dev do
puts "Starting up development Jekyll site server..."
system "SSL_CERT_FILE=./_repos/cacert.pem bundle exec jekyll serve --incremental --watch --force_polling --lsi --config _config.yml,_config.dev.yml -o"
end
desc "Serve production Jekyll site locally"
task :prod do
puts "Starting up production Jekyll site server..."
system "SSL_CERT_FILE=./_repos/cacert.pem bundle exec jekyll serve --no-watch"
end
end
# Usage: rake build, rake build:dev, rake build:drafts
task :build => ["build:prod"]
namespace :build do
desc "Regenerate files for production"
task :prod do
puts "* Regenerating files for production..."
system "JEKYLL_ENV=production SSL_CERT_FILE=./_repos/cacert.pem bundle exec jekyll build"
end
desc "Regenerate files for production (Windows systems)"
task :win do
puts "* Regenerating files for production..."
system "SSL_CERT_FILE=./_repos/cacert.pem bundle exec jekyll build"
end
desc "Regenerate files for development"
task :dev do
puts "* Regenerating files for development..."
system "SSL_CERT_FILE=./_repos/cacert.pem bundle exec jekyll build --config _config.yml,_config.dev.yml --profile"
end
desc "Regenerate files and drafts for development"
task :drafts do
puts "* Regenerating files and drafts for development..."
system "SSL_CERT_FILE=./_repos/cacert.pem bundle exec jekyll build --config _config.yml,_config.dev.yml --profile --drafts"
end
end
# Usage: rake push, rake push:aws3
task :push => ["push:aws3"]
namespace :push do
desc "push production Jekyll site to bucket"
task :push do
puts "Shoving _site into production..."
system "s3_website push"
end
desc "Serve production Jekyll site locally"
task :aws3 do
puts "Shoving _site into production s3 bucket…"
system "s3_website push"
end
end