-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathRakefile
101 lines (84 loc) · 2.25 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
#npm --registry http://registry.npm.taobao.org/ install
#require 'html-proofer'
#
# Directories and files generated by this Rakefile
$generated_files = [
]
# ---- Rake tasks
task :default => :serve
desc 'Set up the build environment'
task :init do
# Install packages
sh 'bundle install'
end
desc 'Clean up the generated site'
task :clean do
rm_rf '_site'
rm_rf '_deploy'
rm_rf '.sass-cache'
rm '.jekyll-metadata', :force => true
$generated_files.each{ |d|
rm_rf d
}
end
# Merges assets from the www repo and the docs repo
desc 'Copy assets and includes from the docs repository'
task :copy_assets do
# Create each destination directory, if it doesn't already exist
#['_includes'].each{ |dir_name|
# FileUtils.mkdir_p(dir_name) unless Dir.exists?(dir_name)
#}
#assets_to_copy = [
# {:source => '_jekyll/_includes/.', :target => '_includes/'},
#]
#assets_to_copy.each{ |asset|
# FileUtils.cp_r(asset[:source], asset[:target], :verbose => true)
#}
end
desc 'Build site with Jekyll'
task :build => ['clean', 'copy_assets'] do
jekyll('build')
end
desc 'Start server and regenerate files on change'
task :serve => ['copy_assets'] do
#check_for_required_files(:warning => true)
jekyll('serve')
end
desc 'Start server and regenerate files on dev mode.'
task :dev => ['clean', 'copy_assets'] do
#check_for_required_files(:warning => true)
jekyll('dev')
end
# rake test
desc "build and test website"
task :test do
jekyll('build')
HTMLProofer.check_directory("./_site", {
:assume_extension => true,
:check_favicon => true,
:external_only => true,
:only_4xx => true,
:url_swap => { %r{https://www.markdownguide.org} => '' },
:typhoeus => {
:ssl_verifypeer => false,
:ssl_verifyhost => 0},
verbose => true}).run
end
# ---- Rake functions
# Run Jekyll
def jekyll(opts = '')
if ENV['dev']=='on'
dev = ' --plugins=_plugins,_plugins-dev'
else
dev = ''
end
if opts=='serve'
host_opt = '--watch --host 0.0.0.0'
elsif opts=='dev'
opts = 'serve'
host_opt = '--port 8888 --watch --host 0.0.0.0'
else
host_opt = ''
end
sh "bundle exec jekyll #{opts}#{dev} --trace #{host_opt}"
end